No Description

main.go 1.4KB

    package main import ( "log" "net/http" "time" "code.revolvingcow.com/revolvingcow/loop/environment" "code.revolvingcow.com/revolvingcow/loop/handlers" "github.com/gorilla/mux" ) func main() { log.Print("Configuring environment") time.Local = time.UTC environment.ConfigureEnvironment() r := mux.NewRouter().StrictSlash(false) r.HandleFunc("/", handlers.DefaultHandler) auth := r.PathPrefix("/logon").Subrouter() auth.Methods("POST").HandlerFunc(handlers.LogonHandler) doc := r.PathPrefix("/{user}/edit/{title}").Subrouter() doc.HandleFunc("/preview", handlers.ContentPreviewHandler).Methods("GET") doc.Methods("GET").HandlerFunc(handlers.ContentReadHandler) doc.Methods("POST").HandlerFunc(handlers.ContentCreateHandler) //doc.Methods("POST").HandlerFunc(handlers.ContentUploadHandler) doc.Methods("PUT").HandlerFunc(handlers.ContentUpdateHandler) doc.Methods("DELETE").HandlerFunc(handlers.ContentDeleteHandler) content := r.PathPrefix("/{user}").Subrouter() content.Methods("GET").HandlerFunc(handlers.ContentHandler) article := r.PathPrefix("/{user}/blog/{article}").Subrouter() article.Methods("GET").HandlerFunc(handlers.BlogArticleHandler) blog := r.PathPrefix("/{user}/blog").Subrouter() blog.Methods("GET").HandlerFunc(handlers.BlogHandler) log.Print("Serving content on ", environment.Address()) log.Fatal(http.ListenAndServe(environment.Address(), r)) }