diff --git a/middleware.go b/middleware.go index 4fb5175..2a3aea1 100644 --- a/middleware.go +++ b/middleware.go @@ -79,4 +79,3 @@ func Auth(roles string, h http.HandlerFunc) http.HandlerFunc { h(w, req) } } - diff --git a/middleware/main.go b/middleware/main.go new file mode 100644 index 0000000..e86f039 --- /dev/null +++ b/middleware/main.go @@ -0,0 +1,23 @@ +package middleware + +import ( + "net/http" + + web "git.to-net.rs/marko.tikvic/webutility" +) + +func Headers(h http.HandlerFunc) http.HandlerFunc { + return web.SetHeaders(web.ParseForm(h)) +} + +func AuthOnly(roles string, h http.HandlerFunc) http.HandlerFunc { + return web.SetHeaders(web.ParseForm(web.Auth(roles, h))) +} + +func Full(roles string, h http.HandlerFunc) http.HandlerFunc { + return web.SetHeaders(web.ParseForm(web.Log(web.Auth(roles, h)))) +} + +func Log(h http.HandlerFunc) http.HandlerFunc { + return web.SetHeaders(web.ParseForm(web.Log(h))) +}