1
0
Fork 0
mirror of https://git.sr.ht/~yotam/shavit synced 2024-05-09 11:26:03 +02:00
shavit/logger.go
2019-11-02 14:51:43 +02:00

23 lines
522 B
Go

package main
import (
"log"
gemini "git.sr.ht/~yotam/go-gemini"
)
// LoggingHandler wrap a Gemini handler and log all the requsts and responses
type LoggingHandler struct {
handler gemini.Handler
}
// Handle implement the gemini.Handler interface by logging each request and response
func (h LoggingHandler) Handle(req gemini.Request) gemini.Response {
log.Println("Received request for", req.URL)
res := h.handler.Handle(req)
log.Println("Responsed for", req.URL, "with ", res.Status, res.Meta)
return res
}