feat: go greenlight api wip
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
func (app *application) routes() *httprouter.Router {
|
||||
router := httprouter.New()
|
||||
|
||||
// Convert the notFoundResponse() helper to a http.Handler using the
|
||||
// http.HandlerFunc() adapter, and then set it as the custom error handler for 404
|
||||
// Not Found responses.
|
||||
router.NotFound = http.HandlerFunc(app.notFoundResponse)
|
||||
|
||||
// Likewise, convert the methodNotAllowedResponse() helper to a http.Handler and set
|
||||
// it as the custom error handler for 405 Method Not Allowed responses.
|
||||
router.MethodNotAllowed = http.HandlerFunc(app.methodNotAllowedResponse)
|
||||
|
||||
router.HandlerFunc(http.MethodGet, "/v1/healthcheck", app.healthcheckHandler)
|
||||
router.HandlerFunc(http.MethodPost, "/v1/movies", app.createMovieHandler)
|
||||
router.HandlerFunc(http.MethodGet, "/v1/movies/:id", app.showMovieHandler)
|
||||
|
||||
return router
|
||||
}
|
||||
Reference in New Issue
Block a user