started with post editor
This commit is contained in:
@ -28,11 +28,13 @@ func main() {
|
||||
db := model.Init()
|
||||
blg := blog.New(db)
|
||||
r := mux.NewRouter()
|
||||
r.Use(cors.HandlerForOrigin("*"))
|
||||
r.Handle("/login", auth.Login(user, password, []byte(secret))).Methods("POST")
|
||||
r.Handle("/posts", auth.Authenticated([]byte(secret))(blg.CreatePost)).Methods("POST")
|
||||
r.Handle("/posts", http.HandlerFunc(blg.GetAllPosts)).Methods("GET")
|
||||
|
||||
r.Use(cors.HandlerForOrigin("*"))
|
||||
|
||||
r.Methods("OPTIONS").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// The CORS middleware should set up the headers for you
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
http.ListenAndServe(":8080", r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user