handles
parent
dc510edfe8
commit
e8193e627a
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue