Skip to content

Quick Start

Build a working application with session management, a health check endpoint, and a custom homepage.

1. Create the Project

mkdir myapp && cd myapp
go mod init myapp
go get github.com/oliverandrich/burrow@latest

2. Write main.go

package main

import (
    "context"
    "log"
    "net/http"
    "os"

    "github.com/oliverandrich/burrow"
    "github.com/go-chi/chi/v5"
    "github.com/urfave/cli/v3"
)

// homeApp is a minimal app with a single route.
type homeApp struct{}

func (a *homeApp) Name() string                        { return "home" }
func (a *homeApp) Register(_ *burrow.AppConfig) error   { return nil }
func (a *homeApp) Routes(r chi.Router) {
    r.Method("GET", "/", burrow.Handle(func(w http.ResponseWriter, r *http.Request) error {
        return burrow.Text(w, http.StatusOK, "Hello from Burrow!")
    }))
}

func main() {
    srv := burrow.NewServer(
        &homeApp{},
    )

    cmd := &cli.Command{
        Name:    "myapp",
        Usage:   "My application",
        Version: "0.1.0",
        Flags:   srv.Flags(nil),
        Action:  srv.Run,
    }

    if err := cmd.Run(context.Background(), os.Args); err != nil {
        log.Fatal(err)
    }
}

This shows the core pattern: define an app, implement Routes(), and use burrow.Handle() to write handlers that return errors. No layout needed yet — that comes later when you want to render HTML templates (see the Tutorial).

3. Run It

go run main.go

The server starts on localhost:8080 with a SQLite database at app.db (auto-created with WAL mode).

4. Test It

curl http://localhost:8080/
# Hello from Burrow!

5. Configure It

Override defaults with CLI flags, environment variables, or a TOML config file:

go run main.go --port 3000 --database-dsn ./myapp.db
PORT=3000 DATABASE_DSN=./myapp.db go run main.go

See Configuration for the full reference.

Next Steps