diff --git a/app/index/handler.go b/app/index/handler.go index 83e13bd..a52d5e5 100644 --- a/app/index/handler.go +++ b/app/index/handler.go @@ -11,7 +11,7 @@ import ( func Handle(conf *common.Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) - fmt.Printf("testje") + fmt.Fprintf(w, "This is a Jamstack microservice endpoint.\nWanna start jammin' too? Go to https://github.com/wgroeneveld/go-jamming !") } } diff --git a/app/pingback/handler.go b/app/pingback/handler.go new file mode 100644 index 0000000..7ef3272 --- /dev/null +++ b/app/pingback/handler.go @@ -0,0 +1,14 @@ + +package pingback + +import ( + "net/http" + + "github.com/wgroeneveld/go-jamming/common" +) + +func Handle(conf *common.Config) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + } +} + diff --git a/app/routes.go b/app/routes.go index f743122..0e19fe5 100644 --- a/app/routes.go +++ b/app/routes.go @@ -4,11 +4,15 @@ package app import ( "github.com/wgroeneveld/go-jamming/app/index" "github.com/wgroeneveld/go-jamming/app/webmention" + "github.com/wgroeneveld/go-jamming/app/pingback" ) -// stole bits from https://pace.dev/blog/2018/05/09/how-I-write-http-services-after-eight-years.html +// stole ideas from https://pace.dev/blog/2018/05/09/how-I-write-http-services-after-eight-years.html // not that contempt with passing conf, but can't create receivers on non-local types, and won't move specifics into package app func (s *server) routes() { - s.router.HandleFunc("/", index.Handle(s.conf)) - s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.Handle(s.conf))) + s.router.HandleFunc("/", index.Handle(s.conf)).Methods("GET") + s.router.HandleFunc("/pingback", pingback.Handle(s.conf)).Methods("POST") + s.router.HandleFunc("/webmention", webmention.HandlePost(s.conf)).Methods("POST") + s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.HandleGet(s.conf))).Methods("GET") + s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.HandlePut(s.conf))).Methods("PUT") } diff --git a/app/webmention/handler.go b/app/webmention/handler.go index 7afb38b..0bc57e0 100644 --- a/app/webmention/handler.go +++ b/app/webmention/handler.go @@ -3,11 +3,24 @@ package webmention import ( "net/http" + "fmt" "github.com/wgroeneveld/go-jamming/common" ) -func Handle(conf *common.Config) http.HandlerFunc { +func HandleGet(conf *common.Config) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + fmt.Println("handling get") + } +} + +func HandlePut(conf *common.Config) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + fmt.Println("handling put") + } +} + +func HandlePost(conf *common.Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { } }