mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 09:49:12 +00:00
25 lines
449 B
Go
25 lines
449 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/syumai/workers"
|
|
)
|
|
|
|
func main() {
|
|
http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) {
|
|
msg := "Hello!"
|
|
w.Write([]byte(msg))
|
|
})
|
|
http.HandleFunc("/echo", func(w http.ResponseWriter, req *http.Request) {
|
|
b, err := io.ReadAll(req.Body)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
io.Copy(w, bytes.NewReader(b))
|
|
})
|
|
workers.Serve(nil) // use http.DefaultServeMux
|
|
}
|