fix(api, docs): send HTTP 400 on empty User-Agent, update docs

This commit is contained in:
Iris System
2023-02-27 09:34:48 +13:00
parent b2c61e3e8e
commit 5e60dec6ec
3 changed files with 12 additions and 2 deletions

View File

@@ -50,7 +50,9 @@ type ProxyHandler struct{}
func (p ProxyHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
if r.Header.Get("User-Agent") == "" {
// please set a valid user-agent
rw.WriteHeader(403)
rw.Header().Set("content-type", "application/json")
rw.WriteHeader(400)
rw.Write([]byte(`{"message":"A valid User-Agent header is required.","code":0}`))
return
}