Added login, some auth methods and a couple routes with no implementation
This commit is contained in:
parent
f76aa74179
commit
f1cae0d660
79 changed files with 8971 additions and 10 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
//go:embed static/*
|
||||
|
@ -36,9 +37,8 @@ func (w *WebServer) RegisterRoutes(api *api.API) {
|
|||
r := mux.NewRouter()
|
||||
apiRouter := r.PathPrefix("/api").Subrouter()
|
||||
|
||||
apiRouter.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "SAMPLE TOKEN")
|
||||
}).Methods("POST")
|
||||
apiRouter.HandleFunc("/login", api.Login).Methods("POST")
|
||||
apiRouter.HandleFunc("/user", api.CreateUser).Methods("POST")
|
||||
|
||||
staticFSSub, _ := fs.Sub(staticFS, "static")
|
||||
staticFSHandler := StaticFSHandler{http.FileServer(http.FS(staticFSSub))}
|
||||
|
@ -52,6 +52,7 @@ func (w *WebServer) RegisterRoutes(api *api.API) {
|
|||
}
|
||||
|
||||
func (w *WebServer) Start() error {
|
||||
log.Debug().Msg("starting webserver")
|
||||
if err := w.Server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
return err
|
||||
}
|
||||
|
@ -59,5 +60,6 @@ func (w *WebServer) Start() error {
|
|||
}
|
||||
|
||||
func (w *WebServer) Close() error {
|
||||
log.Debug().Msg("closing webserver")
|
||||
return w.Server.Close()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue