25 lines
546 B
Go
Raw Normal View History

2024-01-17 17:46:44 +09:00
package main
import (
"encoding/json"
"fmt"
"net/http"
"github.com/syumai/workers"
"github.com/syumai/workers/cloudflare/incoming"
)
func main() {
handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
p := incoming.NewProperties(req.Context())
2024-01-18 21:43:17 +09:00
encoder := json.NewEncoder(w)
w.Header().Set("Content-Type", "application/json")
if err := encoder.Encode(p); err != nil {
http.Error(w, fmt.Sprintf("Error encoding JSON: %v", err), http.StatusInternalServerError)
return
}
2024-01-17 17:46:44 +09:00
})
workers.Serve(handler)
}