Create auth API & comment code

This commit is contained in:
Kevin Kandlbinder 2022-02-23 18:58:46 +01:00
parent 1b15b12859
commit c8d1c33cb4
17 changed files with 475 additions and 101 deletions

35
internal/web/web.go Normal file
View file

@ -0,0 +1,35 @@
package web
import (
"github.com/Unkn0wnCat/matrix-veles/internal/web/api"
"github.com/gorilla/mux"
"github.com/spf13/viper"
"log"
"net/http"
"time"
)
func StartServer() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
//r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
apiRouter := r.PathPrefix("/api").Subrouter()
api.SetupAPI(apiRouter)
srv := &http.Server{
Handler: r,
Addr: viper.GetString("bot.web.listen"),
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Printf("Now serving web-interface on http://%s", viper.GetString("bot.web.listen"))
log.Fatal(srv.ListenAndServe())
}
func HomeHandler(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(200)
writer.Write([]byte("hello world"))
}