Skip to content

Instantly share code, notes, and snippets.

@VojtechVitek
Last active January 26, 2016 02:43
Show Gist options
  • Select an option

  • Save VojtechVitek/81f8018e69e4f879cf5b to your computer and use it in GitHub Desktop.

Select an option

Save VojtechVitek/81f8018e69e4f879cf5b to your computer and use it in GitHub Desktop.
subrouters.go
package main
import (
"log"
"net/http"
"github.com/pressly/chi"
)
func main() {
r := chi.NewRouter()
// Public routes.
r.Group(func(r chi.Router) {
r.Use(InjectAnonymousToken)
// Can't be under TokenRefresh middleware.
r.Delete("/session", session.Logout)
})
// Auth'd routes.
r.Group(func(r chi.Router) {
r.Use(TokenRefresh)
r.Use(Authenticator)
r.Mount("/session", session.Routes())
})
http.ListenAndServe(":3333", r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment