⚠️ [RESEARCH ONLY] This project is a local replica of past commonly used infrastructure architectural philosophies. It is maintained for record-keeping and architectural learning, and is NOT intended for production use.
// Traditional: Manual route registration
r.GET("/", homeHandler)
r.GET("/users/:id", userHandler)
r.GET("/api/v1/users", apiV1UserHandler)
// ... dozens more routes
// Gortex: Automatic discovery from struct tags
type HandlersManager struct {
Home *HomeHandler `url:"/"`
Users *UserHandler `url:"/users/:id"`
API *APIGroup `url:"/api"`
}go get github.com/yshengliao/gortexpackage main
import (
"github.com/yshengliao/gortex/core/app"
"github.com/yshengliao/gortex/core/types"
)
type HandlersManager struct {
Home *HomeHandler `url:"/"`
Users *UserHandler `url:"/users/:id"`
Admin *AdminGroup `url:"/admin" middleware:"auth"`
}
type HomeHandler struct{}
func (h *HomeHandler) GET(c types.Context) error {
return c.JSON(200, map[string]string{"message": "Welcome to Gortex!"})
}
type UserHandler struct{}
func (h *UserHandler) GET(c types.Context) error {
return c.JSON(200, map[string]string{"id": c.Param("id")})
}
type AdminGroup struct {
Dashboard *DashboardHandler `url:"/dashboard"`
}
type DashboardHandler struct{}
func (h *DashboardHandler) GET(c types.Context) error {
return c.JSON(200, map[string]string{"data": "admin only"})
}
func main() {
app, _ := app.NewApp(
app.WithHandlers(&HandlersManager{
Home: &HomeHandler{},
Users: &UserHandler{},
Admin: &AdminGroup{
Dashboard: &DashboardHandler{},
},
}),
)
app.Run() // :8080
}type HandlersManager struct {
Users *UserHandler `url:"/users/:id"` // Dynamic params
Static *FileHandler `url:"/static/*"` // Wildcards
API *APIGroup `url:"/api"` // Nested groups
Profile *ProfileHandler `url:"/profile" middleware:"jwt"` // Protected
Chat *ChatHandler `url:"/chat" hijack:"ws"` // WebSocket
}type UserHandler struct{}
func (h *UserHandler) GET(c types.Context) error { /* GET /users/:id */ }
func (h *UserHandler) POST(c types.Context) error { /* POST /users/:id */ }
func (h *UserHandler) DELETE(c types.Context) error { /* DELETE /users/:id */ }
func (h *UserHandler) Profile(c types.Context) error { /* POST /users/:id/profile */ }// Via struct tags
type HandlersManager struct {
Public *PublicHandler `url:"/public"`
Private *PrivateHandler `url:"/private" middleware:"auth"`
Admin *AdminHandler `url:"/admin" middleware:"auth,rbac"`
}
// Or globally
app.Router().Use(middleware.Logger(logger), middleware.RequestID())cfg := config.NewConfigBuilder().
LoadYamlFile("config.yaml"). // Local dev
LoadDotEnv(".env"). // Overrides
LoadEnvironmentVariables("GORTEX"). // K8s env injection
MustBuild()| Category | Features |
|---|---|
| Routing | Struct-tag auto-discovery, segment-trie, nested groups, zero-allocation context pooling |
| Security | Path-traversal-safe File, origin-locked Redirect, CORS guard, 1 MiB body cap, CSRF, secret redaction |
| Observability | Jaeger/OTel tracing, sharded metrics, health checks (healthy/degraded/unhealthy), /_routes & /_monitor |
| Resilience | Circuit breaker, token-bucket rate limiter with TTL cleanup, graceful shutdown |
| Real-time | WebSocket Hub with read-size limits, type whitelist, and authoriser hooks |
Routing hot path achieves 0 allocations per request (Apple M3 Pro, Go 1.25):
| Benchmark | ns/op | B/op | allocs/op |
|---|---|---|---|
Static route (/api/v1/health) |
~71 | 0 | 0 |
Param route (/users/:id) |
~65 | 0 | 0 |
| Deep params (3 params, 7 segments) | ~134 | 0 | 0 |
Wildcard (/static/*) |
~58 | 0 | 0 |
| JSON response | ~308 | 416 | 5 |
go run ./examples/basic # Struct-tag routing, binder, middleware chain
go run ./examples/auth # JWT login / refresh / /me
go run ./examples/websocket # Hub with message limits and authoriserFull technical documentation is available in both English and Traditional Chinese:
- 📖 English Documentation — API reference, security guide, architecture philosophy, design patterns, best practices
- 📖 繁體中文文件 — API 參考、安全指南、架構哲學、設計模式、最佳實踐
- 🔒 SECURITY.md — Vulnerability reporting process
- Documentation audit: fixed typos, verified all Chinese text uses Taiwanese Traditional Chinese terminology.
- Updated
CLAUDE.mdwith current performance data and feature inventory. - Updated
SECURITY.mdsupported version line. - Consolidated version references across all docs.
- Zero-allocation routing: eliminated
map[string]stringandstrings.Splitfrom hot path; embeddedresponseWriterin pooled context. 0 allocs/op for static, param, wildcard, and deep-param routes.
- Simplified root READMEs; moved detailed content to
docs/index pages. - Added deployment guide (Dockerfile, Docker Compose, K8s manifests, DevOps notes).
- Restructured
docs/intodocs/en/anddocs/zh-tw/with full bilingual coverage. - Added architecture philosophy and design patterns learning guide.
- Marked as research and architectural record project.
- Security hardening (body cap, idempotent shutdown, rate limiter TTL).
- Removed duplicate router; dependency count reduced from 50 → 41 modules.
- Path-traversal-safe file serving, CORS/CSRF/JWT hardening.
- 8-level severity tracing, ShardedCollector, CI/CD pipeline.
MIT License — see LICENSE.