Removed net/http
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.akyoto.dev/go/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := web.NewServer()
|
||||
|
||||
s.Use(func(ctx web.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
defer func() {
|
||||
fmt.Println(ctx.Request().Path(), time.Since(start))
|
||||
}()
|
||||
|
||||
return ctx.Next()
|
||||
})
|
||||
|
||||
s.Run(":8080")
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.akyoto.dev/go/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := web.NewServer()
|
||||
|
||||
s.Get("/", func(ctx web.Context) error {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Request().Context().Done():
|
||||
return nil
|
||||
|
||||
case <-ticker.C:
|
||||
ctx.Response().WriteString("Hello\n")
|
||||
ctx.Response().Flush()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
s.Run(":8080")
|
||||
}
|
Reference in New Issue
Block a user