Skip to main content
Fuego applications can be configured through the options pattern, configuration files, or environment variables.

Config Struct

The Config struct holds all application configuration.
type Config struct {
    AppDir      string
    StaticDir   string
    TemplateDir string
    Port        string
    Host        string
    Dev         bool
}

AppDir

Type: string
Default: "app"
Directory containing route files, middleware, pages, and proxy.
app := fuego.New(fuego.WithAppDir("routes"))
Type: string
Default: "static"
Directory for static files (CSS, JS, images).
app := fuego.New(fuego.WithStaticDir("public"))
Files are served at /static/* by default.
Type: string
Default: ""
Directory for Go templates (if using html/template instead of templ).
app := fuego.New(fuego.WithTemplateDir("templates"))
Type: string
Default: "3000"
Port to listen on. Can be overridden by PORT environment variable.
app := fuego.New(fuego.WithPort("8080"))
Type: string
Default: "0.0.0.0"
Host to bind to.
app := fuego.New(fuego.WithHost("127.0.0.1"))
Type: bool
Default: false
Enable development mode with debug logging.
app := fuego.New(fuego.WithDev(true))
Can be set via FUEGO_DEV=true environment variable.

Options Pattern

Use option functions when creating an app:
app := fuego.New(
    fuego.WithAppDir("routes"),
    fuego.WithStaticDir("public"),
    fuego.WithPort("8080"),
    fuego.WithHost("127.0.0.1"),
    fuego.WithDev(true),
)

Available Options

OptionDescription
WithAppDir(dir)Set the app directory
WithStaticDir(dir)Set the static files directory
WithTemplateDir(dir)Set the template directory
WithPort(port)Set the server port
WithHost(host)Set the server host
WithDev(enabled)Enable/disable development mode

fuego.yaml Configuration

Create a fuego.yaml file in your project root for persistent configuration:
# fuego.yaml
app_dir: app
static_dir: static
port: 3000
host: 0.0.0.0
dev: false
Configuration precedence (highest to lowest):
  1. Option functions passed to fuego.New()
  2. Environment variables
  3. fuego.yaml file
  4. Default values

Environment Variables

VariableDescriptionDefault
PORTServer port3000
HOSTServer host0.0.0.0
FUEGO_DEVDevelopment mode (true/false)false
FUEGO_LOG_LEVELLog level (debug, info, warn, error, off)info
GO_ENVEnvironment (development, production, test)-

Log Level Behavior

GO_ENVFUEGO_DEVDefault Log Level
productionfalsewarn
developmenttruedebug
--info

Request Logger Configuration

Configure the built-in request logger:
app.SetLogger(fuego.RequestLoggerConfig{
    Level:         fuego.LogLevelInfo,
    ShowIP:        true,
    ShowUserAgent: false,
    SkipPaths:     []string{"/health", "/metrics"},
    SkipStatic:    true,
})

RequestLoggerConfig Fields

Type: LogLevel
Default: LogLevelInfo
Minimum log level for requests.
LevelLogs
LogLevelDebugAll requests
LogLevelInfoAll requests
LogLevelWarn4xx and 5xx only
LogLevelError5xx only
LogLevelOffNothing
app.SetLogger(fuego.RequestLoggerConfig{
    Level: fuego.LogLevelWarn, // Only log errors
})
Type: bool
Default: false
Include client IP address in logs.
[12:34:56] 192.168.1.100 GET /api/users 200 in 45ms
Type: bool
Default: false
Include User-Agent header in logs.
Type: []string
Default: nil
Paths to exclude from logging.
app.SetLogger(fuego.RequestLoggerConfig{
    SkipPaths: []string{"/health", "/metrics", "/favicon.ico"},
})
Type: bool
Default: false
Skip logging for static file requests.
app.SetLogger(fuego.RequestLoggerConfig{
    SkipStatic: true, // Don't log /static/* requests
})

Example Configurations

app := fuego.New(
    fuego.WithDev(true),
    fuego.WithPort("3000"),
)

app.SetLogger(fuego.RequestLoggerConfig{
    Level:         fuego.LogLevelDebug,
    ShowIP:        true,
    ShowUserAgent: true,
})

Next Steps