Rue

High-Performance Go Web Framework

Blazing fast routing, minimal dependencies, and everything you need to build modern web applications.

~8ns Static Route
~27ns Param Route
0 Allocations
go get github.com/ch-hash-lab/rue

Features

๐Ÿš€

Blazing Fast Router

Radix tree-based routing with ~8ns static route matching and zero allocations.

๐Ÿ”Œ

Rich Middleware

Logger, Recovery, CORS, Rate Limiter, JWT, API Key authentication built-in.

๐Ÿ“ฆ

Data Binding

JSON, XML, Form, Query binding with powerful struct validation.

๐Ÿ”—

WebSocket

Full RFC 6455 implementation with Hub for broadcasting.

๐Ÿ“ก

SSE & GraphQL

Server-Sent Events and GraphQL with built-in Playground UI.

โšก

QUIC/HTTP3

Next-generation protocol support via quic-go.

๐ŸŽฏ

gRPC Integration

Seamless gRPC support with middleware adapter.

๐Ÿ—œ๏ธ

Compression

Gzip and Brotli with automatic content negotiation.

Quick Start

package main

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

func main() {
    r := rue.Default()

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

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

    r.Run(":8080")
}
package main

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

func main() {
    r := rue.New()

    // Built-in middleware
    r.Use(rue.Logger())
    r.Use(rue.Recovery())
    r.Use(rue.CORS())
    r.Use(rue.RateLimiter(100, 200))
    r.Use(rue.Compress())

    // JWT protected routes
    api := r.Group("/api")
    api.Use(rue.JWT([]byte("secret")))
    {
        api.GET("/profile", getProfile)
    }

    r.Run(":8080")
}
package main

import "github.com/ch-hash-lab/rue"

func main() {
    r := rue.Default()
    hub := rue.NewWebSocketHub()
    go hub.Run()

    r.GET("/ws", func(c *rue.Context) {
        handler := &rue.WebSocketHandler{
            Hub: hub,
            OnMessage: func(conn *rue.WebSocketConn, t int, data []byte) {
                hub.Broadcast(t, data)
            },
        }
        handler.Handle(c)
    })

    r.Run(":8080")
}
package main

import "github.com/ch-hash-lab/rue"

func main() {
    r := rue.Default()

    schema := &rue.GraphQLSchema{
        Query: &rue.ObjectType{
            Name: "Query",
            Fields: map[string]*rue.Field{
                "hello": {
                    Type: rue.StringType,
                    Resolve: func(ctx *rue.ResolveContext) (any, error) {
                        return "Hello, GraphQL!", nil
                    },
                },
            },
        },
    }

    handler := rue.NewGraphQLHandler(schema)
    r.POST("/graphql", handler.Handle)
    r.GET("/graphql", handler.Playground)

    r.Run(":8080")
}

Benchmarks

Benchmark Iterations Time/op Bytes/op Allocs/op
Router_StaticRoute 145,144,989 8.35 ns 0 B 0
Router_ParamRoute 44,290,861 26.83 ns 32 B 1
Engine_SimpleRoute 3,112,678 387.5 ns 1064 B 11
Engine_JSONResponse 1,598,793 778.3 ns 1633 B 18
Brotli Compression 66,400 18.1 ยตs 15920 B 14

Ready to build something fast?

Get started with Rue in minutes.

Read the Docs