-
Notifications
You must be signed in to change notification settings - Fork 15
/
router.go
40 lines (32 loc) · 623 Bytes
/
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
38
39
40
package main
import (
"github.com/gorilla/mux"
"net/http"
)
type Route struct {
Path string
Methods []string
Handler http.Handler
}
type Routes []Route
var routes = Routes{
Route{
"/calls/incoming",
[]string{"GET"},
NewAppHandler(&IncomingConferenceHandler{}),
},
Route{
"/calls/conferences",
[]string{"POST"},
NewAppHandler(&IncomingConferenceHandler{}),
},
}
// Router defines the routes for the API and
// returns a *mux.Router
func Router() *mux.Router {
r := mux.NewRouter()
for _, route := range routes {
r.Handle(route.Path, route.Handler).Methods(route.Methods...)
}
return r
}