mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
28 lines
608 B
Go
28 lines
608 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/syumai/workers"
|
|
"github.com/syumai/workers/cloudflare/fetch"
|
|
)
|
|
|
|
func main() {
|
|
handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
p, err := fetch.NewIncomingProperties(req.Context())
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
encoder := json.NewEncoder(w)
|
|
w.Header().Set("Content-Type", "application/json")
|
|
if err := encoder.Encode(p); err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
})
|
|
workers.Serve(handler)
|
|
}
|