Removed net/http

This commit is contained in:
Eduard Urbach 2024-03-26 22:46:16 +01:00
parent 5a8de525a4
commit ee653a173b
Signed by: eduard
GPG key ID: 49226B848C78F6C8
11 changed files with 230 additions and 629 deletions

View file

@ -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")
}

View file

@ -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")
}