🐹 Web Hash Directives (Advanced) - Go
Web Hash Directives (Advanced) - Go
🎯 What Are Advanced Web Hash Directives?
Advanced web hash directives in TuskLang (#web
) let you define custom routing, middleware chains, and dynamic web behaviors in Go projects.
🚀 Why Advanced Web Directives Matter
- Enable complex, context-aware web routing - Support for multi-domain, versioned APIs, and dynamic middleware
📋 Advanced Web Directive Patterns
- Dynamic Routing: Path params, wildcards, regex
- Versioned APIs: /v1/
, /v2/
routing
- Domain Routing: Host-based rules
- Middleware Chains: Per-route, per-group
- Custom Handlers: Inline or referenced
🔧 Example
web_routes: #web("""
GET /v1/users -> v1.GetUsers
GET /v2/users -> v2.GetUsers
GET /admin/* -> admin.Auth,admin.Dashboard
GET /{lang}/docs -> docs.Handler
GET /static/* -> static.Serve
""")
web_domains: #web("api.example.com: /api/* -> api.Handler")