Added admin admin test user

This commit is contained in:
2022-01-31 12:47:06 +01:00
parent d8aeba7ff6
commit 2a30d8f0ff
2 changed files with 13 additions and 8 deletions

Binary file not shown.

21
main.go
View File

@@ -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)
}))
}