Quick Start

Build your first API endpoint in under 1 minutes.


Basic Server

Create a file named main.go and populate it with the following code to start a basic Routix server.

package main

import (
    "github.com/ramusaaa/routix"
)

func main() {
    // 1. Initialize Route
    r := routix.New()

    // 2. Define a route
    r.GET("/", func(c *routix.Context) error {
        return c.JSON(200, map[string]string{
            "message": "Hello from Routix!",
            "status":  "ok",
        })
    })

    // 3. Define a route with parameters
    r.GET("/users/:name", func(c *routix.Context) error {
        name := c.Params["name"]
        return c.String(200, "Hello, %s!", name)
    })

    // 4. Start the server
    r.Start(":8080")
}

Run It

Run the application using the Go CLI:

go run main.go

Now open your browser to localhost:8080 to see the JSON response.