mirror of
https://git.sr.ht/~yotam/shavit
synced 2024-11-23 00:42:10 +01:00
Add logging for requests
This commit is contained in:
parent
89276ae650
commit
3fbc877dda
20
logger.go
Normal file
20
logger.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.sr.ht/~yotam/go-gemini"
|
||||
)
|
||||
|
||||
type LoggingHandler struct {
|
||||
handler gemini.Handler
|
||||
}
|
||||
|
||||
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
|
||||
}
|
4
main.go
4
main.go
@ -18,7 +18,9 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = gemini.ListenAndServe("", cfg.TLSCert, cfg.TLSKey, MainHandler{absSourceDir})
|
||||
handler := LoggingHandler{MainHandler{absSourceDir}}
|
||||
|
||||
err = gemini.ListenAndServe("", cfg.TLSCert, cfg.TLSKey, handler)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user