update vendor

This commit is contained in:
Ian Kent 2017-04-16 23:43:20 +01:00
parent 5c4899c652
commit 2789ba59d7
No known key found for this signature in database
GPG key ID: CE5AC689AF520A48
5 changed files with 118 additions and 44 deletions

View file

@ -2,6 +2,7 @@ gorilla/mux
=== ===
[![GoDoc](https://godoc.org/github.com/gorilla/mux?status.svg)](https://godoc.org/github.com/gorilla/mux) [![GoDoc](https://godoc.org/github.com/gorilla/mux?status.svg)](https://godoc.org/github.com/gorilla/mux)
[![Build Status](https://travis-ci.org/gorilla/mux.svg?branch=master)](https://travis-ci.org/gorilla/mux) [![Build Status](https://travis-ci.org/gorilla/mux.svg?branch=master)](https://travis-ci.org/gorilla/mux)
[![Sourcegraph](https://sourcegraph.com/github.com/gorilla/mux/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/mux?badge)
![Gorilla Logo](http://www.gorillatoolkit.org/static/images/gorilla-icon-64.png) ![Gorilla Logo](http://www.gorillatoolkit.org/static/images/gorilla-icon-64.png)
@ -23,6 +24,7 @@ The name mux stands for "HTTP request multiplexer". Like the standard `http.Serv
* [Install](#install) * [Install](#install)
* [Examples](#examples) * [Examples](#examples)
* [Matching Routes](#matching-routes) * [Matching Routes](#matching-routes)
* [Listing Routes](#listing-routes)
* [Static Files](#static-files) * [Static Files](#static-files)
* [Registered URLs](#registered-urls) * [Registered URLs](#registered-urls)
* [Full Example](#full-example) * [Full Example](#full-example)
@ -65,8 +67,11 @@ r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`: The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`:
```go ```go
vars := mux.Vars(request) func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) {
category := vars["category"] vars := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Category: %v\n", vars["category"])
}
``` ```
And this is all you need to know about the basic usage. More advanced options are explained below. And this is all you need to know about the basic usage. More advanced options are explained below.
@ -164,6 +169,42 @@ s.HandleFunc("/{key}/", ProductHandler)
s.HandleFunc("/{key}/details", ProductDetailsHandler) s.HandleFunc("/{key}/details", ProductDetailsHandler)
``` ```
### Listing Routes
Routes on a mux can be listed using the Router.Walk method—useful for generating documentation:
```go
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func handler(w http.ResponseWriter, r *http.Request) {
return
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", handler)
r.HandleFunc("/products", handler)
r.HandleFunc("/articles", handler)
r.HandleFunc("/articles/{id}", handler)
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
t, err := route.GetPathTemplate()
if err != nil {
return err
}
fmt.Println(t)
return nil
})
http.Handle("/", r)
}
```
### Static Files ### Static Files
Note that the path provided to `PathPrefix()` represents a "wildcard": calling Note that the path provided to `PathPrefix()` represents a "wildcard": calling

View file

@ -47,12 +47,21 @@ variable will be anything until the next slash. For example:
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler) r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler) r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
Groups can be used inside patterns, as long as they are non-capturing (?:re). For example:
r.HandleFunc("/articles/{category}/{sort:(?:asc|desc|new)}", ArticlesCategoryHandler)
The names are used to create a map of route variables which can be retrieved The names are used to create a map of route variables which can be retrieved
calling mux.Vars(): calling mux.Vars():
vars := mux.Vars(request) vars := mux.Vars(request)
category := vars["category"] category := vars["category"]
Note that if any capturing groups are present, mux will panic() during parsing. To prevent
this, convert any capturing groups to non-capturing, e.g. change "/{sort:(asc|desc)}" to
"/{sort:(?:asc|desc)}". This is a change from prior versions which behaved unpredictably
when capturing groups were present.
And this is all you need to know about the basic usage. More advanced options And this is all you need to know about the basic usage. More advanced options
are explained below. are explained below.

View file

@ -109,6 +109,13 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash,
if errCompile != nil { if errCompile != nil {
return nil, errCompile return nil, errCompile
} }
// Check for capturing groups which used to work in older versions
if reg.NumSubexp() != len(idxs)/2 {
panic(fmt.Sprintf("route %s contains capture groups in its regexp. ", template) +
"Only non-capturing groups are accepted: e.g. (?:pattern) instead of (pattern)")
}
// Done! // Done!
return &routeRegexp{ return &routeRegexp{
template: template, template: template,

View file

@ -153,7 +153,7 @@ func (r *Route) addRegexpMatcher(tpl string, matchHost, matchPrefix, matchQuery
} }
r.regexp = r.getRegexpGroup() r.regexp = r.getRegexpGroup()
if !matchHost && !matchQuery { if !matchHost && !matchQuery {
if len(tpl) == 0 || tpl[0] != '/' { if len(tpl) > 0 && tpl[0] != '/' {
return fmt.Errorf("mux: path must start with a slash, got %q", tpl) return fmt.Errorf("mux: path must start with a slash, got %q", tpl)
} }
if r.regexp.path != nil { if r.regexp.path != nil {

99
vendor/vendor.json vendored
View file

@ -9,10 +9,10 @@
"revisionTime": "2016-08-17T18:46:32Z" "revisionTime": "2016-08-17T18:46:32Z"
}, },
{ {
"checksumSHA1": "oDsOWp1nBMGpQ9gCFnczGADwZTE=", "checksumSHA1": "zmCk+lgIeiOf0Ng9aFP9aFy8ksE=",
"path": "github.com/gorilla/mux", "path": "github.com/gorilla/mux",
"revision": "0a192a193177452756c362c20087ddafcf6829c4", "revision": "599cba5e7b6137d46ddf58fb1765f5d928e69604",
"revisionTime": "2016-09-02T15:33:43Z" "revisionTime": "2017-02-28T22:43:54Z"
}, },
{ {
"checksumSHA1": "41syjEeyv9W/6j89XArd1yyWNBU=", "checksumSHA1": "41syjEeyv9W/6j89XArd1yyWNBU=",
@ -22,9 +22,10 @@
}, },
{ {
"checksumSHA1": "hEnH6sgR83Qfx7UNnphNNlelmj0=", "checksumSHA1": "hEnH6sgR83Qfx7UNnphNNlelmj0=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/gorilla/websocket",
"path": "github.com/gorilla/websocket", "path": "github.com/gorilla/websocket",
"revision": "a91eba7f97777409bc2c443f5534d41dd20c5720", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-03-19T17:27:27Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "jOXIxsHHi2+Kq4evLnADdtynshs=", "checksumSHA1": "jOXIxsHHi2+Kq4evLnADdtynshs=",
@ -64,27 +65,31 @@
}, },
{ {
"checksumSHA1": "kaSS4mHWwdHmFfq8jJAWI8rXkVE=", "checksumSHA1": "kaSS4mHWwdHmFfq8jJAWI8rXkVE=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/ian-kent/goose",
"path": "github.com/ian-kent/goose", "path": "github.com/ian-kent/goose",
"revision": "c3541ea826ad9e0f8a4a8c15ca831e8b0adde58c", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2014-12-21T09:00:59Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "8a3jdb/e82m61ZwOgB2NbxuTjIc=", "checksumSHA1": "8a3jdb/e82m61ZwOgB2NbxuTjIc=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/ian-kent/linkio",
"path": "github.com/ian-kent/linkio", "path": "github.com/ian-kent/linkio",
"revision": "77fb4b01842cb4b019137c0227df9a8f9779d0bd", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2014-12-29T11:24:53Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "L6/CjN/3IdKLxfaBGRPTJ7e62bg=", "checksumSHA1": "L6/CjN/3IdKLxfaBGRPTJ7e62bg=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/jtolds/gls",
"path": "github.com/jtolds/gls", "path": "github.com/jtolds/gls",
"revision": "bb0351aa7eb6f322f32667d51375f26a2bca6628", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-12-28T00:43:38Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "ucMoXRa6ccPO5FyBzhey+N+IOsA=", "checksumSHA1": "ucMoXRa6ccPO5FyBzhey+N+IOsA=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/mailhog/data",
"path": "github.com/mailhog/data", "path": "github.com/mailhog/data",
"revision": "024d554958b5bea5db220bfd84922a584d878ded", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-04-16T19:13:44Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "vyMXU+/pSliAx1yRf6YdKRhF9Ik=", "checksumSHA1": "vyMXU+/pSliAx1yRf6YdKRhF9Ik=",
@ -100,15 +105,17 @@
}, },
{ {
"checksumSHA1": "eD34ZZL4TFFtDl7tCXMEpp+tDSU=", "checksumSHA1": "eD34ZZL4TFFtDl7tCXMEpp+tDSU=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/mailhog/smtp",
"path": "github.com/mailhog/smtp", "path": "github.com/mailhog/smtp",
"revision": "0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-11-19T23:01:07Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "o0iY7SpW0phHTRA/xW3O2CyNLF8=", "checksumSHA1": "qS2ZuuROIJkl8JkMxZrtX8BxTgA=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/mailhog/storage",
"path": "github.com/mailhog/storage", "path": "github.com/mailhog/storage",
"revision": "6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-04-16T22:27:39Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "mbhJnsNwGAwkTQH5c2hVRO9YmxA=", "checksumSHA1": "mbhJnsNwGAwkTQH5c2hVRO9YmxA=",
@ -117,40 +124,46 @@
"revisionTime": "2016-01-29T03:59:39Z" "revisionTime": "2016-01-29T03:59:39Z"
}, },
{ {
"checksumSHA1": "RPVh5/wbvFG0q0CWHXifXpkYTDg=", "checksumSHA1": "4FUjSj4CbaZxSPOGl2zwfyaSFWI=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/assertions",
"path": "github.com/smartystreets/assertions", "path": "github.com/smartystreets/assertions",
"revision": "26acb9229f421449ac63d014995b282d59261a8b", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-12-13T22:48:10Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "Vzb+dEH/LTYbvr8RXHmt6xJHz04=", "checksumSHA1": "Vzb+dEH/LTYbvr8RXHmt6xJHz04=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/assertions/internal/go-render/render",
"path": "github.com/smartystreets/assertions/internal/go-render/render", "path": "github.com/smartystreets/assertions/internal/go-render/render",
"revision": "26acb9229f421449ac63d014995b282d59261a8b", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-12-13T22:48:10Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "dSZQzhiGN0tEILHxUZcrFFNW2Xw=", "checksumSHA1": "r6FauVdOTFnwYQgrKGFuWUbIAJE=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/assertions/internal/oglematchers",
"path": "github.com/smartystreets/assertions/internal/oglematchers", "path": "github.com/smartystreets/assertions/internal/oglematchers",
"revision": "26acb9229f421449ac63d014995b282d59261a8b", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-12-13T22:48:10Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "/mwAihy9AmznMzmbPQ5nWJXBiRU=", "checksumSHA1": "/mwAihy9AmznMzmbPQ5nWJXBiRU=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey",
"path": "github.com/smartystreets/goconvey/convey", "path": "github.com/smartystreets/goconvey/convey",
"revision": "3bd662eac601ad6436e64776af2e112069eb2edc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-01-10T12:00:22Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "9LakndErFi5uCXtY1KWl0iRnT4c=", "checksumSHA1": "9LakndErFi5uCXtY1KWl0iRnT4c=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey/gotest",
"path": "github.com/smartystreets/goconvey/convey/gotest", "path": "github.com/smartystreets/goconvey/convey/gotest",
"revision": "3bd662eac601ad6436e64776af2e112069eb2edc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-01-10T12:00:22Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "FWDhk37bhAwZ2363D/L2xePwR64=", "checksumSHA1": "FWDhk37bhAwZ2363D/L2xePwR64=",
"origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey/reporting",
"path": "github.com/smartystreets/goconvey/convey/reporting", "path": "github.com/smartystreets/goconvey/convey/reporting",
"revision": "3bd662eac601ad6436e64776af2e112069eb2edc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2017-01-10T12:00:22Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "s0GYwa3YNJJXON/b+6ci2Sz9mEw=", "checksumSHA1": "s0GYwa3YNJJXON/b+6ci2Sz9mEw=",
@ -185,27 +198,31 @@
}, },
{ {
"checksumSHA1": "o+ZqT87RLprKCGKMboo5vCxdAvA=", "checksumSHA1": "o+ZqT87RLprKCGKMboo5vCxdAvA=",
"origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2",
"path": "gopkg.in/mgo.v2", "path": "gopkg.in/mgo.v2",
"revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-06-09T18:00:28Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "zTjQOFGy4XTv4L33Kd2FhrV+mbM=", "checksumSHA1": "zTjQOFGy4XTv4L33Kd2FhrV+mbM=",
"origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2/bson",
"path": "gopkg.in/mgo.v2/bson", "path": "gopkg.in/mgo.v2/bson",
"revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-06-09T18:00:28Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "CkCDTsyN2Lbj1cL8+oaYKoPpI9w=", "checksumSHA1": "CkCDTsyN2Lbj1cL8+oaYKoPpI9w=",
"origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2/internal/sasl",
"path": "gopkg.in/mgo.v2/internal/sasl", "path": "gopkg.in/mgo.v2/internal/sasl",
"revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-06-09T18:00:28Z" "revisionTime": "2017-04-16T22:43:02Z"
}, },
{ {
"checksumSHA1": "+1WDRPaOphSCmRMxVPIPBV4aubc=", "checksumSHA1": "JJZ3MTX3hHZ+VTXWhrGSk7MWqgY=",
"origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2/internal/scram",
"path": "gopkg.in/mgo.v2/internal/scram", "path": "gopkg.in/mgo.v2/internal/scram",
"revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903",
"revisionTime": "2016-06-09T18:00:28Z" "revisionTime": "2017-04-16T22:43:02Z"
} }
], ],
"rootPath": "github.com/mailhog/MailHog" "rootPath": "github.com/mailhog/MailHog"