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:

  1. Start with router-only examples (simple, fast)
  2. Add services and DI when needed (gradual)
  3. Enable auto-router for new features (optional)
  4. 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)?

Want more? β†’ Explore Track 2 for DI and auto-router!

Completed Track 2 (Framework)?


πŸ’‘ 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>