Added admin admin test user
This commit is contained in:
21
main.go
21
main.go
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
@@ -50,6 +49,13 @@ func setupApi(r *mux.Router) {
|
||||
r.HandleFunc("/api/article", api.Article).Methods(http.MethodPost, http.MethodPatch, http.MethodDelete)
|
||||
|
||||
r.HandleFunc("/api/assets", api.Assets).Methods(http.MethodGet, http.MethodPost, http.MethodDelete)
|
||||
|
||||
r.MethodNotAllowedHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
api.ApiError{Message: "invalid method", Code: http.StatusNotFound}.Send(w)
|
||||
}))
|
||||
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
api.ApiError{Message: "invalid endpoint", Code: http.StatusNotFound}.Send(w)
|
||||
}))
|
||||
}
|
||||
|
||||
func setupFrontend(r *mux.Router) {
|
||||
@@ -60,12 +66,11 @@ func setupFrontend(r *mux.Router) {
|
||||
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
|
||||
|
||||
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
||||
|
||||
r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if path.Join(config.Prefix)+"/" == r.URL.Path {
|
||||
landingpage.Execute(w, config.PageBase)
|
||||
} else {
|
||||
server.Error404(w, r)
|
||||
}
|
||||
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
landingpage.Execute(w, config.PageBase)
|
||||
})
|
||||
|
||||
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
server.Error404(w, r)
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user