func requestLoggingWrapper(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		log.Debug().Str("module", "web").Str("remote", req.RemoteAddr).Str("proto", req.Proto).
			Str("method", req.Method).Str("path", req.RequestURI).Msg("Request")
		next.ServeHTTP(w, req)
	})
}
requestLoggingWrapper returns middleware that logs client requests.
package web
import (
	"html/template"
	"net/http"
	"os"
	"github.com/inbucket/inbucket/pkg/config"
	"github.com/rs/zerolog/log"
)
type Handler func(http.ResponseWriter, *http.Request, *Context) error
func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	ctx, err := NewContext(req)
	if err != nil {
		log.Error().Str("module", "web").Err(err).Msg("HTTP failed to create context")
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	defer ctx.Close()
	err = h(w, req, ctx)
	if err != nil {
		log.Error().Str("module", "web").Str("path", req.RequestURI).Err(err).
			Msg("Error handling request")
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
}
func cookieHandler(cookie *http.Cookie, next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		log.Debug().Str("module", "web").Str("remote", req.RemoteAddr).Str("proto", req.Proto).
			Str("method", req.Method).Str("path", req.RequestURI).Msg("Injecting cookie")
		http.SetCookie(w, cookie)
		next.ServeHTTP(w, req)
	})
}
func fileHandler(name string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		f, err := os.Open(name)
		if err != nil {
			log.Error().Str("module", "web").Str("path", req.RequestURI).Str("file", name).Err(err).
				Msg("Error opening file")
			http.Error(w, "Error opening file", http.StatusInternalServerError)
			return
		}
		defer f.Close()
		d, err := f.Stat()
		if err != nil {
			log.Error().Str("module", "web").Str("path", req.RequestURI).Str("file", name).Err(err).
				Msg("Error stating file")
			http.Error(w, "Error opening file", http.StatusInternalServerError)
			return
		}
		http.ServeContent(w, req, d.Name(), d.ModTime(), f)
	})
}
func noMatchHandler(statusCode int, message string) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
		log.Warn().Str("module", "web").Str("remote", req.RemoteAddr).Str("proto", req.Proto).
			Str("method", req.Method).Str("path", req.RequestURI).Msg(message)
		w.WriteHeader(statusCode)
	})
}