Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aisk/route122

Repository files navigation

Route122

Route122 is a Go routing library that vendors Go 1.22's new mux functionality, designed to be easily integrated with non-net/http handler frameworks. It provides the same pattern matching and routing capabilities as Go's standard library while being framework-agnostic.

Installation

go get github.com/aisk/route122@latest

Usage

package main

import (
    "fmt"
    "github.com/aisk/route122"
)

func main() {
    router := route122.New()

    // Register a route
    router.Handle("GET /users/{id}", "userHandler")

    // Match a request
    match, found := router.Match("GET", "", "/users/123")
    if found {
        fmt.Printf("Found route: %s\n", match.Pattern)
        fmt.Printf("Parameters: %v\n", match.Params)
        fmt.Printf("Handler: %v\n", match.Handler)
    }
}

For detailed pattern syntax and advanced usage, please refer to Go's official documentation on pattern-based routing.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages