Lokstra Examples
π― Two learning tracks: Router-only or Full Framework
Choose your learning path based on how you want to use Lokstra.
π― Choose Your Track
Track 1: Router Only (Like Echo, Gin, Chi)
Time: 2-3 hours β’ Use Lokstra as a flexible HTTP router
Learn routing, handlers, and middleware without dependency injection complexity.
π Start with Router Examples
What youβll learn:
- β Basic routing and handlers
- β 29 handler form variations
- β Middleware patterns (global, per-route, groups)
- β Quick prototyping
Perfect for:
- Quick APIs and prototypes
- Learning HTTP routing fundamentals
- Developers familiar with Echo, Gin, or Chi
- Projects that donβt need DI
Track 2: Full Framework (Like NestJS, Spring Boot)
Time: 8-12 hours β’ Use Lokstra as a complete application framework
Learn services, dependency injection, auto-routers, annotations, and deployment patterns.
π Start with Framework Examples
What youβll learn:
- β Service layer and dependency injection
- β
Annotation-driven development (
@RouterService,@Inject,@Route) - β Auto-generated REST routers from service methods
- β Configuration-driven deployment (YAML or Code)
- β Monolith β Microservices migrations
- β External service integration
Perfect for:
- Enterprise applications
- Microservices architectures
- Teams wanting DI and auto-router
- Production-scale projects
- Developers familiar with NestJS decorators or Spring annotations
π Complete Feature Map
| Feature | Track 1 (Router) | Track 2 (Framework) |
|---|---|---|
| HTTP Routing | β Core focus | β Included |
| Handler Forms | β 29 variations | β Same flexibility |
| Middleware | β Global, per-route | β Plus registry-based |
| Services | β Not covered | β Core pattern |
| Dependency Injection | β Not needed | β Lazy, type-safe |
| Annotations | β Not covered | β
@RouterService, @Inject, @Route |
| Auto-Router | β Manual only | β From services |
| Configuration | β Code only | β YAML or Code |
| Microservices | β Not covered | β Multi-deployment |
π Can I Switch Tracks?
Yes! Start with Track 1, upgrade to Track 2 later.
Track 1 code is compatible with Track 2. You can:
- Start with router-only examples (simple, fast)
- Add services and DI when needed (gradual)
- Enable auto-router for new features (optional)
- Keep manual routing for existing routes (backward compatible)
Track 1 β Track 2 is an upgrade, not a rewrite!
π Quick Start
For Router Track:
cd docs/00-introduction/examples/router-only/01-hello-world
go run main.go
curl http://localhost:3000/
For Framework Track:
cd docs/00-introduction/examples/full-framework/01-crud-api
go run main.go
curl http://localhost:3000/users
π Whatβs Next?
After examples, continue learning:
Completed Track 1 (Router)?
- Router Guide - Deep dive into routing
- API Reference - Complete API docs
Want more? β Explore Track 2 for DI and auto-router!
Completed Track 2 (Framework)?
- Framework Guide - Advanced DI patterns
- Configuration Schema - Full YAML reference
- Production Patterns - Microservices deployment
π‘ Comparison with Other Frameworks
Track 1 (Router) compares with:
- Echo - Similar flexibility, more handler forms
- Gin - Similar performance, cleaner API
- Chi - Similar routing, more middleware options
- Fiber - Similar speed, Go-idiomatic (no fasthttp)
Track 2 (Framework) compares with:
- NestJS (Node.js) - Similar DI and auto-router concepts
- Spring Boot (Java) - Similar enterprise patterns
- Uber Fx (Go) - Similar DI, plus auto-router
- Buffalo (Go) - Similar full-stack, more flexible
Ready? Choose your track:
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin: 2rem 0;"> <div style="padding: 2rem; border: 2px solid #4a9eff; border-radius: 8px; background: #1a1a2e;"> <h3>π― Track 1: Router Only</h3> <p>Time: 2-3 hours</p> <p>Like: Echo, Gin, Chi</p> <p>Focus: HTTP routing</p> <a href="./router-only/" style="display: inline-block; margin-top: 1rem; padding: 0.5rem 1rem; background: #4a9eff; color: white; text-decoration: none; border-radius: 4px;">Start Router Track β</a> </div>
<div style="padding: 2rem; border: 2px solid #ff6b6b; border-radius: 8px; background: #1a1a2e;"> <h3>ποΈ Track 2: Full Framework</h3> <p>Time: 8-12 hours</p> <p>Like: NestJS, Spring Boot</p> <p>Focus: Enterprise apps</p> <a href="./full-framework/" style="display: inline-block; margin-top: 1rem; padding: 0.5rem 1rem; background: #ff6b6b; color: white; text-decoration: none; border-radius: 4px;">Start Framework Track β</a> </div> </div>