2021-04-07 10:06:16 +02:00
|
|
|
|
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/wgroeneveld/go-jamming/app/index"
|
2021-04-07 11:29:21 +02:00
|
|
|
"github.com/wgroeneveld/go-jamming/app/webmention"
|
2021-04-07 11:44:58 +02:00
|
|
|
"github.com/wgroeneveld/go-jamming/app/pingback"
|
2021-04-07 10:06:16 +02:00
|
|
|
)
|
|
|
|
|
2021-04-07 11:44:58 +02:00
|
|
|
// stole ideas from https://pace.dev/blog/2018/05/09/how-I-write-http-services-after-eight-years.html
|
2021-04-07 11:29:21 +02:00
|
|
|
// not that contempt with passing conf, but can't create receivers on non-local types, and won't move specifics into package app
|
2021-04-07 17:31:23 +02:00
|
|
|
// https://blog.questionable.services/article/http-handler-error-handling-revisited/ is the better idea, but more work
|
2021-04-07 10:06:16 +02:00
|
|
|
func (s *server) routes() {
|
2021-04-07 11:44:58 +02:00
|
|
|
s.router.HandleFunc("/", index.Handle(s.conf)).Methods("GET")
|
2021-04-09 12:40:37 +02:00
|
|
|
s.router.HandleFunc("/pingback", pingback.HandlePost(s.conf)).Methods("POST")
|
2021-04-07 11:44:58 +02:00
|
|
|
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")
|
2021-04-07 10:06:16 +02:00
|
|
|
}
|
2021-04-07 17:31:23 +02:00
|
|
|
|