forked from pivotal-cf/brokerapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_router.go
37 lines (28 loc) · 843 Bytes
/
http_router.go
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
30
31
32
33
34
35
36
37
package brokerapi
import (
"net/http"
"github.com/gorilla/mux"
)
type httpRouter struct {
muxRouter *mux.Router
}
func newHttpRouter() httpRouter {
return httpRouter{
muxRouter: mux.NewRouter(),
}
}
func (httpRouter httpRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
httpRouter.muxRouter.ServeHTTP(w, req)
}
func (httpRouter httpRouter) Get(url string, handler http.HandlerFunc) {
httpRouter.muxRouter.HandleFunc(url, handler).Methods("GET")
}
func (httpRouter httpRouter) Put(url string, handler http.HandlerFunc) {
httpRouter.muxRouter.HandleFunc(url, handler).Methods("PUT")
}
func (httpRouter httpRouter) Delete(url string, handler http.HandlerFunc) {
httpRouter.muxRouter.HandleFunc(url, handler).Methods("DELETE")
}
func (httpRouter) Vars(req *http.Request) map[string]string {
return mux.Vars(req)
}