Added middleware support

This commit is contained in:
2024-03-13 20:18:01 +01:00
parent 02328cb41e
commit c13dbc55d2
9 changed files with 135 additions and 157 deletions

24
examples/logger/main.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"time"
"git.akyoto.dev/go/server"
)
func main() {
s := server.New()
s.Use(func(ctx server.Context) error {
start := time.Now()
defer func() {
fmt.Println(ctx.Path(), time.Since(start))
}()
return ctx.Next()
})
s.Run(":8080")
}