Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"net/http"
"github.com/go-http-utils/mux"
)
func main() {
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)
}
Index ¶
- Constants
- type Handler
- type HandlerFunc
- type Mux
- func (m *Mux) Delete(url string, handler Handler) *Mux
- func (m *Mux) Get(url string, handler Handler) *Mux
- func (m *Mux) Handle(method string, url string, handler Handler) *Mux
- func (m *Mux) Head(url string, handler Handler) *Mux
- func (m *Mux) Patch(url string, handler Handler) *Mux
- func (m *Mux) Post(url string, handler Handler) *Mux
- func (m *Mux) Put(url string, handler Handler) *Mux
- func (m Mux) ServeHTTP(res http.ResponseWriter, req *http.Request)
Examples ¶
Constants ¶
View Source
const Version = "0.1.0"
Version is this package's version number.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of an ordinary function as a Handler.
func (HandlerFunc) ServeHTTP ¶
func (f HandlerFunc) ServeHTTP(res http.ResponseWriter, req *http.Request, params map[string]string)
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is the HTTP request multiplexer.
Click to show internal directories.
Click to hide internal directories.