package server import ( "hacklab.nilfm.cc/quartzgun/renderer" "hacklab.nilfm.cc/quartzgun/router" "html/template" "net/http" ) func apiConfigureAdapters(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(201) next.ServeHTTP(w, req) }) } func apiGetAdapters(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(201) next.ServeHTTP(w, req) }) } func apiAdapterSubscribe(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(201) next.ServeHTTP(w, req) }) } func ProtectWithSubscriberKey(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(201) next.ServeHTTP(w, req) }) } func apiMux() http.Handler { errTemplate, err := template.New("err").Parse("{{ $params := (.Context).Value \"params\" }}
{{ $params.ErrorMessage }}
") if err != nil { panic("error template was malformed") } rtr := &router.Router{ Fallback: *errTemplate, } // adapters (POST & GET) rtr.Post("/adapters", ProtectWithSubscriberKey(apiConfigureAdapters(renderer.JSON("data")))) rtr.Get("/adapters", ProtectWithSubscriberKey(apiGetAdapters(renderer.JSON("data")))) // adapters/:name/subscribe rtr.Post(`/adapters/(?P