From f6dce5be207afe2c046e7c1f4073c33a89944080 Mon Sep 17 00:00:00 2001 From: bel Date: Sat, 17 Jun 2023 09:33:19 -0600 Subject: [PATCH] notfound --- vicuna-tools.d/main.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/vicuna-tools.d/main.go b/vicuna-tools.d/main.go index 855add3..635e02f 100644 --- a/vicuna-tools.d/main.go +++ b/vicuna-tools.d/main.go @@ -139,8 +139,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) error { http.Redirect(w, r, "/", http.StatusTemporaryRedirect) return nil default: - http.NotFound(w, r) - return errors.New("not found") + return handleNotFound(w, r) } } @@ -158,8 +157,7 @@ func handleUI(w http.ResponseWriter, r *http.Request) error { w.Write(htmlChatBot) return nil default: - http.NotFound(w, r) - return errors.New("not found: " + r.URL.Path) + return handleNotFound(w, r) } } @@ -198,7 +196,7 @@ func parseCookieFromCookie(r *http.Request) (Cookie, error) { func (cookie Cookie) Verify() error { if cookie.Name == "" { - return errors.New("incomplete cookie") + return fmt.Errorf("incomplete cookie") } return nil } @@ -218,5 +216,20 @@ func handleAPI(w http.ResponseWriter, r *http.Request) error { http.Redirect(w, r, "/login", http.StatusTemporaryRedirect) return err } + + switch r.URL.Path { + case "/api/v0/chatbot": + return handleAPIChatBot(w, r) + default: + return handleNotFound(w, r) + } +} + +func handleNotFound(w http.ResponseWriter, r *http.Request) error { + http.NotFound(w, r) + return fmt.Errorf("not found: %s %s", r.Method, r.URL.Path) +} + +func handleAPIChatBot(w http.ResponseWriter, r *http.Request) error { return errors.New("not impl") }