1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

authentication

This commit is contained in:
Laura
2025-08-16 17:18:48 +02:00
parent a138378f19
commit e10c3dce3f
7 changed files with 357 additions and 18 deletions

18
main.go
View File

@@ -34,14 +34,22 @@ func main() {
r.Get("/-/data", func(w http.ResponseWriter, r *http.Request) {
RespondJson(w, http.StatusOK, map[string]any{
"version": Version,
"search": env.Tokens.Exa != "",
"models": models,
"authentication": env.Authentication.Enabled,
"authenticated": IsAuthenticated(r),
"search": env.Tokens.Exa != "",
"models": models,
"version": Version,
})
})
r.Get("/-/stats/{id}", HandleStats)
r.Post("/-/chat", HandleChat)
r.Post("/-/auth", HandleAuthentication)
r.Group(func(gr chi.Router) {
gr.Use(Authenticate)
gr.Get("/-/stats/{id}", HandleStats)
gr.Post("/-/chat", HandleChat)
})
log.Info("Listening at http://localhost:3443/")
http.ListenAndServe(":3443", r)