Removed net/http

This commit is contained in:
2024-03-26 22:46:16 +01:00
parent f4617248d8
commit 271e1cd5bd
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")
}