Mercurial > gemma
annotate pkg/controllers/fwa.go @ 5195:d6710d29516b new-fwa
Started to move code around.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 07 May 2020 15:46:51 +0200 |
parents | 445daeefca7b |
children | 5bc8daa986d9 |
rev | line source |
---|---|
5184
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018, 2019, 2020 by via donau |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package controllers |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
5195
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
17 "log" |
5184
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "net/http" |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 "github.com/gorilla/mux" |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 ) |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
5195
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
23 func fairwayAvailability(rw http.ResponseWriter, req *http.Request) { |
5184
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 vars := mux.Vars(req) |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 switch vars["kind"] { |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 case "bottleneck": |
5195
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
29 fairwayAvailabilityBottleneck(rw, req) |
5184
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 case "stretch": |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 case "section": |
5195
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
32 default: |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
33 http.Error(rw, "Invalid kind type.", http.StatusBadRequest) |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
34 return |
5184
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 // TODO: Implement me! |
445daeefca7b
Added controller stub for new fairway availability.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
5195
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
39 |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
40 func fairwayAvailabilityBottleneck(rw http.ResponseWriter, req *http.Request) { |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
41 |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
42 vars := mux.Vars(req) |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
43 |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
44 bottleneckID := vars["name"] |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
45 if bottleneckID == "" { |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
46 http.Error(rw, "missing bottleneck_id", http.StatusBadRequest) |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
47 return |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
48 } |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
49 log.Printf("info: fairway availability for bottleneck_id '%s'\n", bottleneckID) |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
50 |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
51 // TODO: Implement me! |
d6710d29516b
Started to move code around.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5184
diff
changeset
|
52 } |