You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package restlet
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func CommonLogging(next http.Handler, wl ...io.Writer) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if len(wl) > 0 {
|
|
_, _ = wl[0].Write([]byte(fmt.Sprintf("%s - %s\n", r.Method, r.RequestURI)))
|
|
}
|
|
log.Println(r.Method, "-", r.RequestURI)
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|