notfound
parent
f0289d774e
commit
f6dce5be20
|
|
@ -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")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue