feat(rate): add customizable X-Powered-By header

This commit is contained in:
sam 2024-09-10 18:49:25 +02:00
parent 3d22385689
commit 8054d68f79
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
2 changed files with 7 additions and 1 deletions

View file

@ -25,6 +25,7 @@ type Handler struct {
Port int `json:"port"`
ProxyTarget string `json:"proxy_target"`
Debug bool `json:"debug"`
PoweredBy string `json:"powered_by"`
limiter *Limiter
proxy *httputil.ReverseProxy
@ -32,6 +33,10 @@ type Handler struct {
}
func (hn *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if hn.PoweredBy != "" {
w.Header().Set("X-Powered-By", hn.PoweredBy)
}
// all public api endpoints are prefixed with this
if !strings.HasPrefix(r.URL.Path, "/api/v2") {
w.WriteHeader(http.StatusNotFound)

View file

@ -1,5 +1,6 @@
{
"port": 5003,
"proxy_target": "http://localhost:5000",
"debug": true
"debug": true,
"powered_by": "5 gay rats"
}