Skip to content
forked from goji/goji

mroute is a minimalistic and flexible HTTP request multiplexer for Go (golang)

License

Notifications You must be signed in to change notification settings

prasannavl/mroute

 
 

Repository files navigation

mroute

GoDoc Build Status

mroute is a HTTP request multiplexer, similar to net/http.ServeMux. It compares incoming requests to a list of registered Patterns, and dispatches to the mchain.Handler that corresponds to the first matching Pattern. mroute also supports Middleware (composable shared functionality applied to every request) and uses the standard context package to store request-scoped values.

This is a fork of goji adapted to the mchain philosophy of returning errors.

Quick Start

package main

import (
        "fmt"
        "net/http"

        "github.com/prasannavl/mroute"
        "github.com/prasannavl/mroute/pat"
)

func hello(w http.ResponseWriter, r *http.Request) error {
        name := pat.Param(r, "name")
        fmt.Fprintf(w, "Hello, %s!", name)
        return nil
}

func main() {
        mux := mroute.NewMux()
        mux.HandleFunc(pat.Get("/hello/:name"), hello)

        http.ListenAndServe("localhost:8000", mux)
}

Please refer to mroute's GoDoc Documentation for a full API reference.

Related links

mchain: https://github.com/prasannavl/mchain
goji/goji: https://goji.io

Credits

Thanks to goji router - mroute is an adaptation of this fantastic work.

About

mroute is a minimalistic and flexible HTTP request multiplexer for Go (golang)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%