mirror of
https://github.com/ChuckNorrison/LightningTipBot.git
synced 2026-08-20 13:28:08 +02:00
* 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
23 lines
443 B
Go
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)
|
|
}
|