master
bel 2023-06-17 09:08:20 -06:00
parent dc510edfe8
commit e8193e627a
1 changed files with 21 additions and 6 deletions

View File

@ -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()