diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index 9ac8718..855add3 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -114,8 +114,10 @@ func _handle(w http.ResponseWriter, r *http.Request) error { switch first { case "login": return handleLogin(w, r) + case "api": + return handleAPI(w, r) default: - return handleLoggedIn(w, r) + return handleUI(w, r) } } @@ -142,13 +144,11 @@ func handleLogin(w http.ResponseWriter, r *http.Request) error { } } -func handleLoggedIn(w http.ResponseWriter, r *http.Request) error { - cookie, err := ParseCookie(r) - if err != nil { +func handleUI(w http.ResponseWriter, r *http.Request) error { + if _, err := ParseCookie(r); err != nil { http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) return err } - _ = cookie switch r.URL.Path { case "/": @@ -212,3 +212,11 @@ func (cookie Cookie) Serialize(w http.ResponseWriter) { } http.SetCookie(w, c) } + +func handleAPI(w http.ResponseWriter, r *http.Request) error { + if _, err := ParseCookie(r); err != nil { + http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) + return err + } + return errors.New("not impl") +} diff --git a/vicuna-tools.d/template.d/index.html b/vicuna-tools.d/template.d/index.html index d00bfd1..ccf2393 100644 --- a/vicuna-tools.d/template.d/index.html +++ b/vicuna-tools.d/template.d/index.html @@ -3,6 +3,9 @@
+