Added middleware support
This commit is contained in:
24
examples/logger/main.go
Normal file
24
examples/logger/main.go
Normal 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")
|
||||
}
|
Reference in New Issue
Block a user