Skip to main content
This guide walks you through creating a Lightning app from scratch, registering a route, and verifying the response with curl.
1

Install Lightning

Add Lightning to your Go module:
If you don’t have a module yet, initialize one first:
2

Create main.go

Create a file named main.go with the following content:
DefaultApp() creates a new application with two middleware functions already registered: Logger(), which logs every request, and Recovery(), which catches panics and returns a 500 response. Use NewApp() if you want a bare application with no middleware.
3

Run the server

Start the server:
You should see output similar to:
Lightning listens on port 6789 by default. You can override this by passing an address to app.Run(), for example app.Run(":8080"), or by setting the PORT environment variable.
4

Test with curl

In a separate terminal, send a request to your running server:
You should receive:
The server terminal will also print a log line for the request, showing the remote address, method, status code, path, and elapsed time.

What’s next

Now that your app is running, explore the core concepts:
  • Routing — add URL parameters, wildcards, and multiple HTTP methods
  • Middleware — write custom middleware and apply it globally or to specific routes
  • Context API — read request data and send structured responses
  • Route groups — organize routes under shared prefixes with scoped middleware