29 lines
382 B
Go
29 lines
382 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"git.akyoto.dev/go/server"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
s := server.New()
|
||
|
|
||
|
s.Get("/", func(ctx server.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")
|
||
|
}
|