stub handling GET /.../messages
This commit is contained in:
@@ -19,6 +19,8 @@ type Config struct {
|
|||||||
SlackToken string
|
SlackToken string
|
||||||
SlackChannels string
|
SlackChannels string
|
||||||
PostgresConn string
|
PostgresConn string
|
||||||
|
BasicAuthUser string
|
||||||
|
BasicAuthPassword string
|
||||||
storage Storage
|
storage Storage
|
||||||
queue Queue
|
queue Queue
|
||||||
driver Driver
|
driver Driver
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -51,6 +51,7 @@ func listenAndServe(ctx context.Context, cfg Config) chan error {
|
|||||||
errc := make(chan error)
|
errc := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(errc)
|
defer close(errc)
|
||||||
|
log.Printf("listening on %s", s.Addr)
|
||||||
errc <- s.ListenAndServe()
|
errc <- s.ListenAndServe()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ func newHandler(cfg Config) http.HandlerFunc {
|
|||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
mux.Handle("POST /api/v1/events/slack", http.HandlerFunc(newHandlerPostAPIV1EventsSlack(cfg)))
|
mux.Handle("POST /api/v1/events/slack", http.HandlerFunc(newHandlerPostAPIV1EventsSlack(cfg)))
|
||||||
|
mux.Handle("GET /api/v1/messages", http.HandlerFunc(newHandlerGetAPIV1Message(cfg)))
|
||||||
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
if cfg.Debug {
|
if cfg.Debug {
|
||||||
@@ -73,6 +75,17 @@ func newHandler(cfg Config) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newHandlerGetAPIV1Message(cfg Config) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if u, p, _ := r.BasicAuth(); u != cfg.BasicAuthUser || p != cfg.BasicAuthPassword {
|
||||||
|
http.Error(w, "shoo", http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Error(w, "not impl", http.StatusNotImplemented)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func newHandlerPostAPIV1EventsSlack(cfg Config) http.HandlerFunc {
|
func newHandlerPostAPIV1EventsSlack(cfg Config) http.HandlerFunc {
|
||||||
if cfg.InitializeSlack {
|
if cfg.InitializeSlack {
|
||||||
return handlerPostAPIV1EventsSlackInitialize
|
return handlerPostAPIV1EventsSlackInitialize
|
||||||
|
|||||||
Reference in New Issue
Block a user