Skip to content

Commit

Permalink
Add documentation for Bind()
Browse files Browse the repository at this point in the history
  • Loading branch information
muir committed Mar 30, 2022
1 parent f24ac0f commit 6fdebad
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func (mux *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
mux.router.ServeHTTP(w, r)
}

// Bind validates that the injection chains for all routes are valid.
// If any are not, an error is returned. If you do not call bind, and
// there are any invalid injection chains, then routes will panic when
// used.
func (mux *Mux) Bind() error {
router := httprouter.New()
for _, opt := range mux.options {
Expand Down Expand Up @@ -125,15 +129,27 @@ func (mux *Mux) Use(providers ...interface{}) {
mux.providers = mux.providers.Append(n, translateMiddleware(providers)...)
}

func (mux *Mux) Get(path string, providers ...interface{}) { mux.Method("GET", path, providers...) }
func (mux *Mux) Head(path string, providers ...interface{}) { mux.Method("HEAD", path, providers...) }
func (mux *Mux) Post(path string, providers ...interface{}) { mux.Method("POST", path, providers...) }
func (mux *Mux) Put(path string, providers ...interface{}) { mux.Method("PUT", path, providers...) }
// Get establish a route for HTTP GET requests
func (mux *Mux) Get(path string, providers ...interface{}) { mux.Method("GET", path, providers...) }

// Head establish a route for HTTP HEAD requests
func (mux *Mux) Head(path string, providers ...interface{}) { mux.Method("HEAD", path, providers...) }

// Post establish a route for HTTP POST requests
func (mux *Mux) Post(path string, providers ...interface{}) { mux.Method("POST", path, providers...) }

// Put establish a route for HTTP PUT requests
func (mux *Mux) Put(path string, providers ...interface{}) { mux.Method("PUT", path, providers...) }

// Patch establish a route for HTTP PATCH requests
func (mux *Mux) Patch(path string, providers ...interface{}) { mux.Method("PATCH", path, providers...) }

// Options establish a route for HTTP OPTIONS requests.
func (mux *Mux) Options(path string, providers ...interface{}) {
mux.Method("OPTIONS", path, providers...)
}

// Delete establish a route for HTTP DELETE requests.
func (mux *Mux) Delete(path string, providers ...interface{}) {
mux.Method("DELETE", path, providers...)
}

0 comments on commit 6fdebad

Please sign in to comment.