Getting Started with Rue

Rue is a high-performance, feature-rich web framework for Go with minimal dependencies. It's designed to be fast, flexible, and easy to use.

Features

Installation

Rue requires Go 1.21 or later. Install it using go get:

bash
go get github.com/ch-hash-lab/rue

Quick Start

Create a new file main.go:

go
package main

import (
    "net/http"
    "github.com/ch-hash-lab/rue"
)

func main() {
    // Create engine with default middleware (Logger + Recovery)
    r := rue.Default()

    // Simple route
    r.GET("/", func(c *rue.Context) {
        c.JSON(http.StatusOK, rue.H{"message": "Hello, Rue!"})
    })

    // Path parameters
    r.GET("/users/:id", func(c *rue.Context) {
        id := c.Param("id")
        c.JSON(http.StatusOK, rue.H{"user_id": id})
    })

    // Query parameters
    r.GET("/search", func(c *rue.Context) {
        q := c.Query("q")
        page := c.DefaultQuery("page", "1")
        c.JSON(http.StatusOK, rue.H{"query": q, "page": page})
    })

    // Start server
    r.Run(":8080")
}

Run your application:

bash
go run main.go

Visit http://localhost:8080 in your browser!

Engine Modes

Rue provides two ways to create an engine:

Default()

Creates an engine with Logger and Recovery middleware pre-configured:

go
r := rue.Default()  // Includes Logger + Recovery

New()

Creates a blank engine without any middleware:

go
r := rue.New()  // No middleware
r.Use(rue.Logger())    // Add manually
r.Use(rue.Recovery())
💡 Tip

Use Default() for most applications. Use New() when you need full control over middleware.

Next Steps