Commit 776b4c95bdc25f2b22c13516b81f3d4c77344d4a
1 parent
18fcd6d6bf
Exists in
master
refactored middleware
Showing
2 changed files
with
23 additions
and
1 deletions
Show diff stats
middleware.go
middleware/main.go
... | ... | @@ -0,0 +1,23 @@ |
1 | +package middleware | |
2 | + | |
3 | +import ( | |
4 | + "net/http" | |
5 | + | |
6 | + web "git.to-net.rs/marko.tikvic/webutility" | |
7 | +) | |
8 | + | |
9 | +func Headers(h http.HandlerFunc) http.HandlerFunc { | |
10 | + return web.SetHeaders(web.ParseForm(h)) | |
11 | +} | |
12 | + | |
13 | +func AuthOnly(roles string, h http.HandlerFunc) http.HandlerFunc { | |
14 | + return web.SetHeaders(web.ParseForm(web.Auth(roles, h))) | |
15 | +} | |
16 | + | |
17 | +func Full(roles string, h http.HandlerFunc) http.HandlerFunc { | |
18 | + return web.SetHeaders(web.ParseForm(web.Log(web.Auth(roles, h)))) | |
19 | +} | |
20 | + | |
21 | +func Log(h http.HandlerFunc) http.HandlerFunc { | |
22 | + return web.SetHeaders(web.ParseForm(web.Log(h))) | |
23 | +} | ... | ... |