Skip to content

go-http-utils/mux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mux

Build Status Coverage Status

HTTP mux for Go.

Installation

go get -u github.com/go-http-utils/mux

Documentation

API documentation can be found here: https://godoc.org/github.com/go-http-utils/mux

Usage

import (
  "github.com/go-http-utils/mux"
)
m := mux.New()

m.Get("/:type(a|b)/:id", mux.HandlerFunc(func(res http.ResponseWriter, req *http.Request, params map[string]string) {
  res.WriteHeader(http.StatusOK)

  fmt.Println(params["type"])
  fmt.Println(params[":id"])

  res.Write([]byte("Hello Worlkd"))
}))

http.ListenAndServe(":8080", m)