notfound
parent
f0289d774e
commit
f6dce5be20
|
|
@ -139,8 +139,7 @@ func handleLogin(w http.ResponseWriter, r *http.Request) error {
|
||||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
http.NotFound(w, r)
|
return handleNotFound(w, r)
|
||||||
return errors.New("not found")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,8 +157,7 @@ func handleUI(w http.ResponseWriter, r *http.Request) error {
|
||||||
w.Write(htmlChatBot)
|
w.Write(htmlChatBot)
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
http.NotFound(w, r)
|
return handleNotFound(w, r)
|
||||||
return errors.New("not found: " + r.URL.Path)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,7 +196,7 @@ func parseCookieFromCookie(r *http.Request) (Cookie, error) {
|
||||||
|
|
||||||
func (cookie Cookie) Verify() error {
|
func (cookie Cookie) Verify() error {
|
||||||
if cookie.Name == "" {
|
if cookie.Name == "" {
|
||||||
return errors.New("incomplete cookie")
|
return fmt.Errorf("incomplete cookie")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -218,5 +216,20 @@ func handleAPI(w http.ResponseWriter, r *http.Request) error {
|
||||||
http.Redirect(w, r, "/login", http.StatusTemporaryRedirect)
|
http.Redirect(w, r, "/login", http.StatusTemporaryRedirect)
|
||||||
return err
|
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")
|
return errors.New("not impl")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue