Created
April 18, 2016 18:25
-
-
Save mattmcla/1fcff4aede62c099d1dc8a6ed6a8d8b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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