Added middleware support
This commit is contained in:
parent
1e8a846457
commit
414f7c6b33
9 changed files with 135 additions and 157 deletions
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")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue