Echo + EdgeOne Pages
High performance, extensible, minimalist Go web framework with Echo. Features middleware, route groups, JSON binding, and dynamic parameters.
cloud-functions/api.go
package main
import (
"github.com/labstack/echo/v4"
)
func main() {
e := echo.New()
e.GET("/", welcome)
e.GET("/health", health)
// Todo CRUD
api := e.Group("/api")
api.GET("/todos", listTodos)
api.POST("/todos", createTodo)
api.GET("/todos/:id", getTodo)
api.PATCH("/todos/:id/toggle", toggleTodo)
api.DELETE("/todos/:id", deleteTodo)
e.Start(":9000")
}API Endpoints
GET/api/
Welcome page listing all available routes
GET/api/health
Health check endpoint with Go runtime info
GET/api/api/todos
GET route returning all todos with total count
POST/api/api/todos
POST route with JSON body binding via c.Bind()
Request Body:
{
"title": "Learn Echo Framework"
}GET/api/api/todos/1
Dynamic route parameter with c.Param("id")
PATCH/api/api/todos/1/toggle
Toggle todo completion status
DELETE/api/api/todos/3
Delete a todo by ID
High Performance
Optimized router with zero dynamic memory allocation
Middleware Support
Rich built-in middleware with easy custom middleware creation
Data Binding
Automatic binding of JSON, XML, and form data to Go structs