forked from wgroeneveld/go-jamming
basic routes all set up
This commit is contained in:
parent
795397aa82
commit
4c01023fcd
|
@ -11,7 +11,7 @@ import (
|
||||||
func Handle(conf *common.Config) http.HandlerFunc {
|
func Handle(conf *common.Config) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
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 !")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,11 +4,15 @@ package app
|
||||||
import (
|
import (
|
||||||
"github.com/wgroeneveld/go-jamming/app/index"
|
"github.com/wgroeneveld/go-jamming/app/index"
|
||||||
"github.com/wgroeneveld/go-jamming/app/webmention"
|
"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
|
// 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() {
|
func (s *server) routes() {
|
||||||
s.router.HandleFunc("/", index.Handle(s.conf))
|
s.router.HandleFunc("/", index.Handle(s.conf)).Methods("GET")
|
||||||
s.router.HandleFunc("/webmention/{domain}/{token}", s.authorizedOnly(webmention.Handle(s.conf)))
|
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")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,24 @@ package webmention
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/wgroeneveld/go-jamming/common"
|
"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) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue