2021-07-28 20:21:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2021-08-01 18:32:40 +00:00
|
|
|
"os"
|
2021-08-01 17:06:33 +00:00
|
|
|
"sirlab.de/go/knyt/application"
|
2021-08-01 18:05:00 +00:00
|
|
|
"sirlab.de/go/knyt/applicationConfig"
|
2021-07-30 14:16:55 +00:00
|
|
|
"sirlab.de/go/knyt/handler"
|
2021-07-28 20:21:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-08-01 18:05:00 +00:00
|
|
|
appConfig := applicationConfig.NewApplicationConfig()
|
2021-08-01 18:32:40 +00:00
|
|
|
app, err := application.NewApplication(appConfig)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("%v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2021-08-01 17:06:33 +00:00
|
|
|
mux := handler.NewAuthMux(app)
|
2021-08-01 13:56:53 +00:00
|
|
|
|
2021-08-01 17:06:33 +00:00
|
|
|
mux.PublicHandleFunc("/__intern__/exit", handler.Exit)
|
2021-08-04 15:10:56 +00:00
|
|
|
mux.PublicHandleFunc("/api/login", mux.Login)
|
|
|
|
mux.PublicHandleFunc("/api/logout", mux.Logout)
|
|
|
|
mux.PrivateHandleFunc("/api/userinfo", mux.GetUserInfo)
|
2022-02-27 19:54:13 +00:00
|
|
|
mux.PrivateHandleFunc("/api/gameinfo", app.GetGameInfo)
|
2021-08-04 23:42:21 +00:00
|
|
|
mux.PrivateHandleFunc("/api/sync", app.SyncHandler)
|
2021-10-01 14:40:07 +00:00
|
|
|
mux.PrivateHandleFunc("/api/collectQuotes", app.CollectQuotes)
|
2021-08-12 23:07:06 +00:00
|
|
|
mux.PrivateHandleFunc("/api/startGame", app.StartGame)
|
2021-08-14 11:21:53 +00:00
|
|
|
mux.PrivateHandleFunc("/api/resetGame", app.ResetGame)
|
2021-08-30 16:21:14 +00:00
|
|
|
mux.PrivateHandleFunc("/api/continueGame", app.ContinueGame)
|
2021-09-24 18:46:10 +00:00
|
|
|
mux.PrivateHandleFunc("/api/finishGame", app.FinishGame)
|
2021-08-30 08:55:07 +00:00
|
|
|
mux.PrivateHandleFunc("/api/saveSelection", app.SaveSelection)
|
2021-10-01 19:19:31 +00:00
|
|
|
mux.PrivateHandleFunc("/api/getQuotes", app.GetQuotes)
|
2021-10-15 21:07:41 +00:00
|
|
|
mux.PrivateHandleFunc("/api/saveQuote", app.SaveQuote)
|
|
|
|
mux.PrivateHandleFunc("/api/removeQuote", app.RemoveQuote)
|
2021-07-28 20:21:14 +00:00
|
|
|
|
|
|
|
// default handler
|
2021-08-01 16:36:02 +00:00
|
|
|
fsHandler := http.FileServer(http.Dir("../../client/dist/"))
|
2021-08-01 17:06:33 +00:00
|
|
|
mux.PublicHandle("/", fsHandler)
|
2021-07-28 20:21:14 +00:00
|
|
|
|
|
|
|
// start listening
|
2021-08-01 17:06:33 +00:00
|
|
|
fmt.Printf("http://localhost:%d/\n", mux.Port)
|
|
|
|
mux.ListenAndServe()
|
2021-07-28 20:21:14 +00:00
|
|
|
}
|