Structured. Scalable. Idiomatic.

Build Go APIs withArchitectural Clarity

A NestJS-inspired dependency injection framework for Go. Build modular, testable applications with a unified architecture for HTTP and WebSocket.

Multi Pipelines, One Stage— Reuse everything

MIT License — Open source and ready for production

user_controller.go
type UserController struct {
  common.REST
  UserService // Injected
}

func (c UserController) READ_BY_ID(param ginject.Param) User {
  // GET /users/:id
  return c.UserService.FindOne(param.Get("id"))
}

Method naming → routes. Type → injected dependencies. No tags. No code generation.

Purpose-Built for Production

Everything you need to build scalable, maintainable web applications in Go.

Dependency Injection

NestJS-inspired Module→Controller→Provider pattern with reflection-based auto-injection. No tags, no annotations.

Execution Safety

Every request carries a cancellable context.Context with metadata and hierarchical SLA timeouts. WS connections get their own root context.

Multi-Transport

WS controllers with event-based routing. Per-connection ExecutionContext, per-message SLA timeouts, and clean shutdown.

Type-Safe

GoSafe launcher checks ctx.Done() before spawning. All WS goroutines are lifecycle-safe and cancel when the connection closes.

Middleware Stack

Composable middleware, guards, interceptors, and exception filters — global or per-route. Built-in CORS, Helmet, CSRF, RequestLogger.

Composable

Sharded in-memory LFU cache with TTL, SetNX atomic operations, Keys/TTL introspection, and a pluggable interface.

Why Ginject

Built Different

A framework designed for how developers actually build applications.

1

One Architecture for All Transports

HTTP, WebSocket, and future protocols all share the same middleware, guards, and interceptors. Build once, deploy everywhere.

  • Shared pipeline stages
  • Code reuse
  • Consistent patterns
2

Zero Configuration

No annotations. No code generation. Just Go. Method names become routes, types are injected automatically via reflection.

  • Convention over config
  • Idiomatic Go
  • Type-safe DI
3

Production-Grade Defaults

Context propagation, goroutine safety, execution-scoped timeouts, and comprehensive error handling built in.

  • Goroutine-safe
  • Context propagation
  • Built-in validation

Ready to build something great?

Learn the Architecture→
Code Example

Convention Over Configuration

No annotations. No code generation. Just Go. Method names become routes, types become dependencies—the framework stays out of your way.

  • Reflection-based DI
  • Type-safe injection
  • Zero configuration
// Automatic routing from method names
"text-violet-400">type "text-blue-300">UserController "text-violet-400">struct {
    common.REST
    "text-blue-300">UserService "text-blue-300">UserService  // Auto-injected
}

"text-violet-400">func (c "text-blue-300">UserController) NewController() core.Controller {
    c.BindGuard(AuthGuard{}, c.CREATE, c.DELETE)
    "text-violet-400">return c
}

// GET /users/:id — Automatic route from method name
"text-violet-400">func (c "text-blue-300">UserController) READ_BY_ID(
    param ginject.Param,
) "text-blue-300">User {
    "text-violet-400">return c."text-blue-300">UserService.FindOne(param.Get("id"))
}

// POST /users
"text-violet-400">func (c "text-blue-300">UserController) CREATE(body ginject.Body) "text-blue-300">User {
    "text-violet-400">var user "text-blue-300">User
    body.Bind(&user)
    "text-violet-400">return c."text-blue-300">UserService.Create(&user)
}

Ginject Request Lifecycle

A unified, intuitive, and predictable lifecycle for HTTP & WebSocket

🌐

HTTP REQUEST LIFECYCLE

Stateless

HTTP
Request
📝
MIDDLEWARE
Request enrichment
🔐
GUARD
Authorization
🔄
INTERCEPTOR
Pre-processing
⚙️
MAIN HANDLER
Business logic
🔄
INTERCEPTOR
Post-processing
EXCEPTION FILTER
Handle Error
✓ RESPONSE Success
⚡

WEBSOCKET MESSAGE LIFECYCLE

Stateful

1. HANDSHAKE (Connection Establishment)
Client
Handshake
GLOBAL MIDDLEWARE
Handshake
MODULE MIDDLEWARE
Handshake
✓ CONNECTION ESTABLISHED
2. MESSAGE PIPELINE (Per Message)
GUARD
Authorization
INTERCEPTOR
Pre-processing
MAIN HANDLER
Business logic
INTERCEPTOR
Post-processing
MODULE EXCEPTION FILTER
Error Handler
GLOBAL EXCEPTION FILTER
Error Handler
ACK / EVENT Send Message

Clean & Intuitive

Simple, linear flow. Easy to understand.

Unified Architecture

Same stages across all transports.

Secure by Default

Guards at every level for protection.

Interceptor Power

Pre & post processing for any logic.

Centralized Errors

Consistent error handling everywhere.

Type Safe

Built with Go. Compiler enforced.

Ginject - Go Dependency Injection Framework | NestJS for Go