Skip to content

Instantly share code, notes, and snippets.

@alexedwards
Created April 20, 2020 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexedwards/947195d45cc2f52e9f4b5addd9cee516 to your computer and use it in GitHub Desktop.
Save alexedwards/947195d45cc2f52e9f4b5addd9cee516 to your computer and use it in GitHub Desktop.
sessionManager = scs.New()
sessionManager.Store = redisstore.New(pool)
standardMiddleware := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
dynamicMiddleware := alice.New(sessionManager.LoadAndSave, noSurf, app.authenticate)
mux := pat.New()
mux.Get("/", dynamicMiddleware.ThenFunc(app.home))
mux.Get("/about", dynamicMiddleware.ThenFunc(app.about))
...
fileServer := http.FileServer(http.Dir("./ui/static/"))
mux.Get("/static/", http.StripPrefix("/static", fileServer))
return standardMiddleware.Then(mux)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment