use go-chi middlewares
go-chi already delivers the middlewares we need so we don't need to import other libraries for that.
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tomasen/realip"
|
||||
)
|
||||
|
||||
// RealIP is a middleware that sets a http.Request RemoteAddr.
|
||||
func RealIP(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if ip := realip.RealIP(r); ip != "" {
|
||||
r.RemoteAddr = ip
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/ascarter/requestid"
|
||||
)
|
||||
|
||||
// RequestID is a convenient middleware to inject a request id.
|
||||
func RequestID(next http.Handler) http.Handler {
|
||||
return requestid.RequestIDHandler(next)
|
||||
}
|
||||
Reference in New Issue
Block a user