Skip to content

Instantly share code, notes, and snippets.

@mattmcla
Created April 18, 2016 18:25
Show Gist options
  • Save mattmcla/1fcff4aede62c099d1dc8a6ed6a8d8b0 to your computer and use it in GitHub Desktop.
Save mattmcla/1fcff4aede62c099d1dc8a6ed6a8d8b0 to your computer and use it in GitHub Desktop.
func main() {
r := httprouter.New()
// Health check
r.GET(“/health”, HealthCheckHandler)
// Authentication
r.POST(“/token-auth”, TokenAuthHandler)
r.POST(“/p”, AuthMiddleware(SomeFormHandler))
fmt.Println(“Starting server on :3030”)
http.ListenAndServe(“:3030”, &Server{r})
}
type Server struct {
r *httprouter.Router
}
func (s *Server) ServeHTTP (w http.ResponseWriter, r *http.Request) {
w.Header().Set(“Access-Control-Allow-Origin”, “*”)
s.r.ServeHTTP(w, r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment