29 lines
379 B
Go
Raw Permalink Normal View History

2024-03-22 13:37:21 +00:00
package main
import (
"time"
2024-03-22 14:08:24 +00:00
"git.akyoto.dev/go/web"
2024-03-22 13:37:21 +00:00
)
func main() {
2024-03-22 14:08:24 +00:00
s := web.NewServer()
2024-03-22 13:37:21 +00:00
2024-03-22 14:08:24 +00:00
s.Get("/", func(ctx web.Context) error {
2024-03-22 13:37:21 +00:00
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")
}