-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.go
27 lines (24 loc) · 873 Bytes
/
routes.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
package main
import (
"github.com/go-chi/chi"
)
func createRoutes() chi.Router {
// We're using chi as the router. You'll want to read
// the documentation https://github.com/go-chi/chi
// so that you can capture parameters like /events/5
// or /api/events/4 -- where you want to get the
// event id (5 and 4, respectively).
r := chi.NewRouter()
r.Get("/", indexController)
r.Get("/about", aboutController)
r.Get("/events/new", CreateEventController)
r.Post("/events/new", CreateEventController)
r.Get("/events/{id}", eventController)
r.Post("/events/{id}", eventRSVPController)
r.Get("/api/events", EventsAPIController)
r.Get("/events/{id}/donate", EventDonationController)
// Create a route for the API endpoint with a dynamic 'id' parameter
r.Get("/api/events/{id}", EventAPIController)
addStaticFileServer(r, "/static/", "staticfiles")
return r
}