2022-05-18 00:16:28 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:16:28 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00
2022-05-18 00:04:37 +09:00

workers

  • workers is a package to run an HTTP server written in Go on Cloudflare Workers.
  • This package can easily serve http.Handler on Cloudflare Workers.

Features

  • serve http.Handler
  • environment variables (WIP)
  • KV (WIP)
  • R2 (WIP)

Installation

go get github.com/syumai/workers

Usage

implement your http.Handler and give it to workers.Serve().

func main() {
	var handler http.HandlerFunc = func (w http.ResponseWriter, req *http.Request) { ... }
	workers.Serve(handler)
}

or just call http.Handle and http.HandleFunc, then invoke workers.Serve() with nil.

func main() {
	http.HandleFunc("/hello", func (w http.ResponseWriter, req *http.Request) { ... })
	workers.Serve(nil) // if nil is given, http.DefaultMux is used.
}

For concrete examples, see examples directory. Currently, all examples use tinygo instead of Go due to binary size issues.

License

MIT

Author

syumai

Description
Go package to run an HTTP server on Cloudflare Workers.
Readme 658 KiB
Languages
Go 68.6%
JavaScript 28.1%
Makefile 2.6%
HTML 0.4%
Shell 0.3%