certViewer/cmd/web/routes.go (18 lines of code) (raw):
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package main
import (
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/justinas/alice"
)
// routes handles the routing for /evready
func (app *application) routes() http.Handler {
router := httprouter.New()
router.NotFound = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
app.notFound(w)
})
fileServer := http.FileServer(http.Dir("./ui/static/"))
router.Handler(http.MethodGet, "/static/*filepath", http.StripPrefix("/static", fileServer))
router.HandlerFunc(http.MethodGet, "/certviewer", app.home)
router.HandlerFunc(http.MethodPost, "/certviewer", app.certPost)
standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
return standard.Then(router)
}