planning to make this some kind of unhinged microfrontend hotwired mess. this is basically the setup walked through in "Lets Go", but pared down. since we plan to ship this in k8s behind nginx and cert-manager, there's no need to do TLS termination in go. i like httprouter and alice, so i'm including them here early. use `go:embed` to get our templates and static assets (neither of which exist yet) into the binary so we can ship this whole thing to a commodity `go` container.
26 lines
501 B
Go
26 lines
501 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
"github.com/justinas/alice"
|
|
|
|
"replication-systems.estradiol.cloud/ui"
|
|
)
|
|
|
|
// routes ...
|
|
func (app *application) routes() http.Handler {
|
|
router := httprouter.New()
|
|
|
|
// setup server for static files
|
|
fileServer := http.FileServer(http.FS(ui.Files))
|
|
router.Handler(http.MethodGet, "/static/*filepath", fileServer)
|
|
|
|
router.HandlerFunc(http.MethodGet, "/", app.home)
|
|
|
|
standard := alice.New()
|
|
|
|
return standard.Then(router)
|
|
}
|