Added admin admin test user
This commit is contained in:
BIN
database.sqlite3
BIN
database.sqlite3
Binary file not shown.
21
main.go
21
main.go
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"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/article", api.Article).Methods(http.MethodPost, http.MethodPatch, http.MethodDelete)
|
||||||
|
|
||||||
r.HandleFunc("/api/assets", api.Assets).Methods(http.MethodGet, http.MethodPost, 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) {
|
func setupFrontend(r *mux.Router) {
|
||||||
@@ -60,12 +66,11 @@ func setupFrontend(r *mux.Router) {
|
|||||||
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
|
r.PathPrefix("/js/").HandlerFunc(server.ServePath)
|
||||||
|
|
||||||
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
||||||
|
r.Path("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
landingpage.Execute(w, config.PageBase)
|
||||||
if path.Join(config.Prefix)+"/" == r.URL.Path {
|
|
||||||
landingpage.Execute(w, config.PageBase)
|
|
||||||
} else {
|
|
||||||
server.Error404(w, r)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
server.Error404(w, r)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user