HttpRouter + EdgeOne Pages
A lightweight high-performance request router with zero garbage collection overhead. Minimal, fast, and reliable.
cloud-functions/api.go
package main
import (
"github.com/julienschmidt/httprouter"
"net/http"
)
func main() {
router := httprouter.New()
router.GET("/", welcome)
router.GET("/health", health)
// Todo CRUD
router.GET("/api/todos", listTodos)
router.POST("/api/todos", createTodo)
router.GET("/api/todos/:id", getTodo)
router.PATCH("/api/todos/:id/toggle", toggleTodo)
router.DELETE("/api/todos/:id", deleteTodo)
http.ListenAndServe(":9000", router)
}API Endpoints
GET/api/
Welcome page listing all available routes
GET/api/health
Health check endpoint returning service status
GET/api/api/todos
GET route returning all todos with total count
POST/api/api/todos
POST route with JSON body to create a new todo
Request Body:
{
"title": "Learn HttpRouter"
}GET/api/api/todos/1
Dynamic route parameter with ps.ByName("id")
PATCH/api/api/todos/1/toggle
Toggle todo completion status
DELETE/api/api/todos/3
Delete a todo by ID
Zero Allocation
No GC overhead — zero dynamic memory allocation in hot paths
Radix Tree
Efficient radix-tree based routing for O(log n) lookups
Minimal & Clean
Lightweight with no dependencies beyond Go standard library