Skip to content

Package pathmux provides a path oriented ("middleware") HTTP handler, which can hand-off to other HTTP handler for each path, for the Go programming language's built-in "net/http" library.

License

Notifications You must be signed in to change notification settings

reiver/go-pathmux

Repository files navigation

go-pathmux

Package pathmux provides a path oriented ("middleware") HTTP handler, which can hand-off to other HTTP handler for each path, for the Go programming language's built-in "net/http" library.

Package pathmux is a HTTP request router, and dispatcher.

The name mux stands for "HTTP request multiplexer".

Similar to the built-in standard http.ServeMux in the "net/http" package, pathmux.Mux matches incoming requests against a list of registered routes and calls a handler for the route that matches the URL or other conditions.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-pathmux

GoDoc

Example

import "github.com/reiver/go-pathmux"

// ...

var mux pathmux.Mux

err := mux.HandlePath(homeHandler, "/")
err := mux.HandlePath(productsHandler, "/products")
err := mux.HandlePath(articlesHandler, "/articles")

err := mux.HandlePattern(productProducer, "/products/{key}")
err := mux.HandlePattern(articleCategoryProducer, "/articles/{category}/")
err := mux.HandlePattern(articleProducer, "/articles/{category}/{article_id}")

// handles: "/app", "/app/", "/app/apple", "/app/banana", "/app/banana/", "/app/banana/peel.jpeg",  "/app/cherry", etc.
err := mux.HandleDirectory(homeHandler, "/app")

// ...

err := http.ListenAndServe(":8080", mux)

Import

To import package pathmux use import code like the follownig:

import "github.com/reiver/go-pathmux"

Installation

To install package pathmux do the following:

GOPROXY=direct go get github.com/reiver/go-pathmux

Author

Package pathmux was written by Charles Iliya Krempeaux

About

Package pathmux provides a path oriented ("middleware") HTTP handler, which can hand-off to other HTTP handler for each path, for the Go programming language's built-in "net/http" library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages