mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 01:39:11 +00:00
F: add incoming property example
This commit is contained in:
parent
bb2644d33f
commit
e5294f4cd2
3
_examples/incoming/.gitignore
vendored
Normal file
3
_examples/incoming/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
node_modules
|
||||||
|
.wrangler
|
12
_examples/incoming/Makefile
Normal file
12
_examples/incoming/Makefile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.PHONY: dev
|
||||||
|
dev:
|
||||||
|
wrangler dev
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
go run ../../cmd/workers-assets-gen
|
||||||
|
tinygo build -o ./build/app.wasm -target wasm -no-debug ./...
|
||||||
|
|
||||||
|
.PHONY: deploy
|
||||||
|
deploy:
|
||||||
|
wrangler deploy
|
7
_examples/incoming/go.mod
Normal file
7
_examples/incoming/go.mod
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module github.com/syumai/workers/_examples/hello
|
||||||
|
|
||||||
|
go 1.21.3
|
||||||
|
|
||||||
|
require github.com/syumai/workers v0.0.0
|
||||||
|
|
||||||
|
replace github.com/syumai/workers => ../../
|
2
_examples/incoming/go.sum
Normal file
2
_examples/incoming/go.sum
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github.com/syumai/workers v0.1.0 h1:z5QfQR2X+PCKzom7RodpI5J4D5YF7NT7Qwzb9AM9dgY=
|
||||||
|
github.com/syumai/workers v0.1.0/go.mod h1:alXIDhTyeTwSzh0ZgQ3cb9HQPyyYfIejupE4Z3efr14=
|
20
_examples/incoming/main.go
Normal file
20
_examples/incoming/main.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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())
|
||||||
|
|
||||||
|
buf, _ := json.Marshal(p)
|
||||||
|
fmt.Fprintf(w, "%s", string(buf))
|
||||||
|
})
|
||||||
|
workers.Serve(handler)
|
||||||
|
}
|
9
_examples/incoming/wrangler.toml
Normal file
9
_examples/incoming/wrangler.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
name = "incoming"
|
||||||
|
main = "./build/worker.mjs"
|
||||||
|
compatibility_date = "2022-05-13"
|
||||||
|
compatibility_flags = [
|
||||||
|
"streams_enable_constructors"
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
command = "make build"
|
Loading…
x
Reference in New Issue
Block a user