diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index cd6599d..e0abe3a 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -105,13 +105,28 @@ func handle(w http.ResponseWriter, r *http.Request) { } func _handle(w http.ResponseWriter, r *http.Request) error { - u, p, ok := r.BasicAuth() - if !ok { - w.Header().Set("WWW-Authenticate", "Basic") - w.WriteHeader(http.StatusUnauthorized) - return errors.New("no auth") + switch r.URL.Path { + case "/login": + return handleLogin(w, r) + case "/": + return handleUI(w, r) + default: + http.NotFound(w, r) + return nil } - _, _ = u, p +} + +func handleLogin(w http.ResponseWriter, r *http.Request) error { + return errors.New("not impl") +} + +func handleUI(w http.ResponseWriter, r *http.Request) error { + cookie, err := ParseCookie(r) + if err != nil { + http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) + return err + } + _ = cookie Config.Semaphore.Lock() defer Config.Semaphore.Unlock()