mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-05-23 05:46:35 +02:00
Create auth API & comment code
This commit is contained in:
parent
1b15b12859
commit
c8d1c33cb4
17 changed files with 475 additions and 101 deletions
35
internal/web/web.go
Normal file
35
internal/web/web.go
Normal 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"))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue