forked from bitrise-io/bitrise-webhooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.go
More file actions
29 lines (25 loc) · 761 Bytes
/
Copy pathroutes.go
File metadata and controls
29 lines (25 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"net/http"
"github.com/bitrise-io/bitrise-webhooks/metrics"
"github.com/bitrise-io/bitrise-webhooks/service"
"github.com/bitrise-io/bitrise-webhooks/service/hook"
"github.com/bitrise-io/bitrise-webhooks/service/root"
"github.com/gorilla/mux"
)
func setupRoutes() {
r := mux.NewRouter()
//
r.HandleFunc("/h/{service-id}/{app-slug}/{api-token}", metrics.WrapHandlerFunc(hook.HTTPHandler)).
Methods("POST")
//
r.HandleFunc("/", metrics.WrapHandlerFunc(root.HTTPHandler)).
Methods("GET")
//
r.NotFoundHandler = http.HandlerFunc(metrics.WrapHandlerFunc(routeNotFoundHandler))
//
http.Handle("/", r)
}
func routeNotFoundHandler(w http.ResponseWriter, r *http.Request) {
service.RespondWithNotFoundError(w, "Not Found")
}