Skip to content

i2bskn/dispatch

Repository files navigation

dispatch

GoDoc Build Status codecov

dispatch is HTTP request multiplexer compatible with ServeMux of net/http.

Dependencies

  • Go 1.7 or lator

No dependency on the third party library.

Installation

go get -u github.com/i2bskn/dispatch

Usage

package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/i2bskn/dispatch"
)

func hello(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello %s!", dispatch.Param(r, "name"))
}

func main() {
	mux := dispatch.New()
	mux.HandleFunc("/hello/:name", hello)
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprint(w, "Home!")
	})
	log.Fatal(http.ListenAndServe(":8080", mux))
}

See also GoDoc.

License

dispatch is available under the MIT.

About

HTTP request multiplexer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published