Skip to main content
Lightning is a Go web framework built for speed and simplicity. It wraps fasthttp to deliver high-throughput HTTP handling while keeping the developer API clean and easy to reason about. You register routes, attach middleware, and write handlers — Lightning takes care of the rest.

Key features

  • Trie-based routing — route matching uses a prefix tree for consistent O(k) performance regardless of how many routes you register
  • Middleware — attach global or route-level middleware using the same func(*Context) signature as handlers
  • Route groups — organize related routes under a shared prefix and apply scoped middleware to the whole group
  • Rich context API — read URL parameters, query strings, headers, cookies, and request bodies; write JSON, XML, HTML, plain text, or file responses — all from a single *Context object
  • Multiple response formatsctx.JSON(), ctx.XML(), ctx.Text(), ctx.HTML(), ctx.File(), ctx.Success(), and ctx.Fail() cover the common cases without any extra setup
  • Built-in Logger and Recovery middlewareDefaultApp() ships with request logging and panic recovery out of the box
  • Graceful shutdownapp.RunGraceful() listens for SIGINT/SIGTERM and drains active connections before exiting
  • Static file serving — serve an entire directory tree with a single app.Static() call

Hello world

package main

import "github.com/go-labx/lightning"

func main() {
    app := lightning.DefaultApp()

    app.Get("/ping", func(ctx *lightning.Context) {
        ctx.JSON(lightning.StatusOK, lightning.Map{
            "message": "pong",
        })
    })

    app.Run()
}
Run the server and hit the endpoint:
go run main.go
curl http://127.0.0.1:6789/ping
# {"message":"pong"}

Next steps

Quick start

Build and run your first Lightning app in minutes

Routing

Learn URL parameters, wildcards, and route registration

Middleware

Add logging, recovery, auth, and more to your handlers

Context API

Access request data and write responses with the Context object