Overview of basic-auth-proxy
mainbasic-auth-proxy is an example of an HTTP proxy server that implements Basic Authentication. It is designed to add Basic-Auth protection to a target URL (e.g., https://syum.ai).repository·main·Indexed 22 days ago
https://github.com/syumai/workersA Go package that enables running Go HTTP servers on Cloudflare Workers by bridging standard Go http.Handler interfaces to the Cloudflare Workers runtime via WebAssembly (Wasm). It includes examples for Basic Authentication proxies, KV storage, Durable Objects, Cron triggers, Cloudflare Queues, and Pages Functions.
basic-auth-proxy is an example of an HTTP proxy server that implements Basic Authentication. It is designed to add Basic-Auth protection to a target URL (e.g., https://syum.ai).r2-image-server is an example Cloudflare Worker implementation that provides a RESTful interface for managing images stored in Cloudflare R2. It allows you to store, retrieve, and delete image objects using specific keys.Cloudflare Workers typically return an HTTP Response and exit immediately. You can extend this lifecycle using two key mechanisms:
WaitUntil: Allows you to execute asynchronous tasks that run in the background without blocking the initial HTTP response. The Workers runtime will keep the worker alive until these tasks are completed.PassThroughOnException: Prevents the worker from returning a runtime error response if an unhandled exception occurs. Instead, the request is forwarded to the origin server as if the worker had not intercepted it.Recommended Pattern for Resilient Logging:
If you are implementing a feature like a log stream that modifies headers (e.g., masking API tokens) but must not crash the service if an error occurs, declare PassThroughOnException first and use WaitUntil for the logging task.
When implementing real-world Cloudflare Queues consumers in Go, be aware of the distinction between blocking and non-blocking consumption.
Note that wrangler does not support running multiple workers interacting with the same local queue simultaneously. For production scenarios, choose between:
queues.Consume: For blocking consumption.queues.ConsumeNonBlock: For non-blocking consumption.To develop or run the r2-image-server, ensure you have the following tools installed globally:
wrangler (Cloudflare CLI)Go version 1.24.0 or laterFor deeper integration details, refer to the Cloudflare R2 runtime APIs documentation and the syumai/workers package documentation.
To develop or deploy this worker, ensure you have the following tools installed globally:
wranglerGo (version 1.24.0 or later)The template includes a Makefile to simplify common development tasks:
make dev: Starts the local development server.make build: Compiles the Go code into a WebAssembly (Wasm) binary.make deploy: Deploys the worker to Cloudflare.To change the name of your worker, edit the name property in the wrangler.toml file.
make dev
make build
make deployTo develop the basic-auth-proxy worker, you must have the following tools installed globally:
wranglerGo (version 1.24.0 or later)To use this template, you must have the following installed on your system:
After scaffolding the project, follow these steps to initialize the Go modules and start the local development server:
go mod init.go mod tidy.npm start.curl.cd my-app
go mod init
go mod tidy
npm start
curl http://localhost:8787/helloThe template includes a Makefile to simplify common development tasks:
make dev: Starts the local development server.make build: Builds the Go Wasm binary.make deploy: Deploys the worker to Cloudflare.make dev
make build
make deployThe following commands are available for managing your Go Worker project lifecycle:
npm start: Runs the development server using Wrangler (enables Cloudflare-specific features).go run .: Runs the dev server without Wrangler (Cloudflare-related features will be unavailable).npm run build: Builds the Go WebAssembly (Wasm) binary.npm run deploy: Deploys the worker to Cloudflare.npm start # run dev server
# or
go run . # run dev server without Wrangler
npm run build # build Go Wasm binary
npm run deploy # deploy worker