func main() { // Create the instance of your router server := mux.NewRouter() // Create a new helen.Static instance. We are passing "static" as the directory // we want to serve static content from. static := helen.NewStatic("fixtures") // We bind anything matching /static/ route to our static handler static.Bind("/static/", server) // You can register other handlers to your server or whatever you want to do with it. log.Fatal(http.ListenAndServe(":8000", server)) }
// Init registers the url routes. func (s *Server) Init() *Server { // normal stuffs s.mux.HandleFunc(HomePath, s.Home) s.mux.HandleFunc(RegisterPath, s.Register) s.mux.HandleFunc(LoginPath, s.Login) s.mux.HandleFunc(LogoutPath, s.Logout) s.mux.HandleFunc(ProfilePath, s.Profile) s.mux.HandleFunc(ClientsPath, s.Client) // oauth stuffs s.mux.HandleFunc(s.cfg.AuthEndpoint, s.Authorize) s.mux.HandleFunc(s.cfg.TokenEndpoint, s.Access) s.mux.HandleFunc(s.cfg.InfoEndpoint, s.Info) // static stuffs h := helen.NewStatic(s.cfg.StaticDir) h.Bind(StaticPath, s) return s }