Mercurial > gemma
annotate pkg/middleware/notfound.go @ 2549:9bf6b767a56a
client: refactored and improved splitscreen for diagrams
To make different diagrams possible, the splitscreen view needed to be decoupled from the cross profiles.
Also the style has changed to make it more consistent with the rest of the app. The standard box header
is now used and there are collapse and expand animations.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 08 Mar 2019 08:50:47 +0100 |
parents | 04967d6565fa |
children | 6f9d00c8cc38 |
rev | line source |
---|---|
1127
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package middleware |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "errors" |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "net/http" |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 ) |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
1494
04967d6565fa
Added api doc strings for the middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1127
diff
changeset
|
21 // ErrNotFound should be as the argument to panic if the NotFound should |
04967d6565fa
Added api doc strings for the middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1127
diff
changeset
|
22 // report back a http.StatusNotFound. |
1127
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 var ErrNotFound = errors.New("Not found") |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
1494
04967d6565fa
Added api doc strings for the middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1127
diff
changeset
|
25 // NotFound creates an http.Handler which survives panic(ErrNotFound) and |
04967d6565fa
Added api doc strings for the middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1127
diff
changeset
|
26 // reports http.StatusNotFound in these cases back to the calling handler. |
1127
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 func NotFound(next http.Handler) http.Handler { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 defer func() { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 if p := recover(); p != nil { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 if p == ErrNotFound { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 http.NotFound(rw, req) |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 } else { |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 panic(p) |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 } |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 }() |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 next.ServeHTTP(rw, req) |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 }) |
71ba4a66ec95
Return 404 if a proxied service is not found.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |