lightningtipbot/internal/api/middleware.go
gohumble 01710f3385
separate lnurl and api server (#261)
* separate lnurl and api server

* add lndhub handler and proxy

* update proxy

* fix AppendRoute with empty methods

* add logs

* fix trace

* dump request

* parse bearer token

* exclude banned users

* exclude banned users

* fix log levels
2022-01-05 00:09:11 +01:00

23 lines
443 B
Go

package api
import (
log "github.com/sirupsen/logrus"
"net/http"
"net/http/httputil"
)
func LoggingMiddleware(prefix string, next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Tracef("[%s]\n%s", prefix, dump(r))
r.BasicAuth()
next.ServeHTTP(w, r)
}
}
func dump(r *http.Request) string {
x, err := httputil.DumpRequest(r, true)
if err != nil {
return ""
}
return string(x)
}