comparison controllers/routes.go @ 239:713234a04a87

Renamed JSONHandler.Process to JSONHandler.Handler as it sounds more symmetrical.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 Jul 2018 17:15:22 +0200
parents 3771788d3dae
children 9012e4045da4
comparison
equal deleted inserted replaced
238:2b39bf2bf1fd 239:713234a04a87
13 api := m.PathPrefix("/api").Subrouter() 13 api := m.PathPrefix("/api").Subrouter()
14 14
15 sysAdmin := auth.EnsureRole("sys_admin") 15 sysAdmin := auth.EnsureRole("sys_admin")
16 16
17 api.Handle("/users", sysAdmin(&JSONHandler{ 17 api.Handle("/users", sysAdmin(&JSONHandler{
18 Input: func() interface{} { return new(User) }, 18 Input: func() interface{} { return new(User) },
19 Process: createUser, 19 Handle: createUser,
20 })).Methods(http.MethodPost) 20 })).Methods(http.MethodPost)
21 21
22 api.Handle("/users/{user}", sysAdmin(&JSONHandler{ 22 api.Handle("/users/{user}", sysAdmin(&JSONHandler{
23 Input: func() interface{} { return new(User) }, 23 Input: func() interface{} { return new(User) },
24 Process: updateUser, 24 Handle: updateUser,
25 })).Methods(http.MethodPut) 25 })).Methods(http.MethodPut)
26 26
27 api.HandleFunc("/login", login). 27 api.HandleFunc("/login", login).
28 Methods(http.MethodGet, http.MethodPost) 28 Methods(http.MethodGet, http.MethodPost)
29 api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(logout))). 29 api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(logout))).