From 2789ba59d79e58ca688fff1bb42acec37e881dfa Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Sun, 16 Apr 2017 23:43:20 +0100 Subject: [PATCH] update vendor --- vendor/github.com/gorilla/mux/README.md | 45 ++++++++++- vendor/github.com/gorilla/mux/doc.go | 9 +++ vendor/github.com/gorilla/mux/regexp.go | 7 ++ vendor/github.com/gorilla/mux/route.go | 2 +- vendor/vendor.json | 99 +++++++++++++++---------- 5 files changed, 118 insertions(+), 44 deletions(-) diff --git a/vendor/github.com/gorilla/mux/README.md b/vendor/github.com/gorilla/mux/README.md index fa79a6b..cdab878 100644 --- a/vendor/github.com/gorilla/mux/README.md +++ b/vendor/github.com/gorilla/mux/README.md @@ -2,6 +2,7 @@ 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) +[![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) @@ -23,6 +24,7 @@ The name mux stands for "HTTP request multiplexer". Like the standard `http.Serv * [Install](#install) * [Examples](#examples) * [Matching Routes](#matching-routes) +* [Listing Routes](#listing-routes) * [Static Files](#static-files) * [Registered URLs](#registered-urls) * [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()`: ```go -vars := mux.Vars(request) -category := vars["category"] +func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) { + 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. @@ -164,6 +169,42 @@ s.HandleFunc("/{key}/", ProductHandler) 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 Note that the path provided to `PathPrefix()` represents a "wildcard": calling diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go index 291ef5e..00daf4a 100644 --- a/vendor/github.com/gorilla/mux/doc.go +++ b/vendor/github.com/gorilla/mux/doc.go @@ -47,12 +47,21 @@ variable will be anything until the next slash. For example: r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler) 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 calling mux.Vars(): vars := mux.Vars(request) 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 are explained below. diff --git a/vendor/github.com/gorilla/mux/regexp.go b/vendor/github.com/gorilla/mux/regexp.go index fd8fe39..0189ad3 100644 --- a/vendor/github.com/gorilla/mux/regexp.go +++ b/vendor/github.com/gorilla/mux/regexp.go @@ -109,6 +109,13 @@ func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash, if errCompile != nil { 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! return &routeRegexp{ template: template, diff --git a/vendor/github.com/gorilla/mux/route.go b/vendor/github.com/gorilla/mux/route.go index 293b6d4..5544c1f 100644 --- a/vendor/github.com/gorilla/mux/route.go +++ b/vendor/github.com/gorilla/mux/route.go @@ -153,7 +153,7 @@ func (r *Route) addRegexpMatcher(tpl string, matchHost, matchPrefix, matchQuery } r.regexp = r.getRegexpGroup() 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) } if r.regexp.path != nil { diff --git a/vendor/vendor.json b/vendor/vendor.json index 71ea64e..ea3320f 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -9,10 +9,10 @@ "revisionTime": "2016-08-17T18:46:32Z" }, { - "checksumSHA1": "oDsOWp1nBMGpQ9gCFnczGADwZTE=", + "checksumSHA1": "zmCk+lgIeiOf0Ng9aFP9aFy8ksE=", "path": "github.com/gorilla/mux", - "revision": "0a192a193177452756c362c20087ddafcf6829c4", - "revisionTime": "2016-09-02T15:33:43Z" + "revision": "599cba5e7b6137d46ddf58fb1765f5d928e69604", + "revisionTime": "2017-02-28T22:43:54Z" }, { "checksumSHA1": "41syjEeyv9W/6j89XArd1yyWNBU=", @@ -22,9 +22,10 @@ }, { "checksumSHA1": "hEnH6sgR83Qfx7UNnphNNlelmj0=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/gorilla/websocket", "path": "github.com/gorilla/websocket", - "revision": "a91eba7f97777409bc2c443f5534d41dd20c5720", - "revisionTime": "2017-03-19T17:27:27Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "jOXIxsHHi2+Kq4evLnADdtynshs=", @@ -64,27 +65,31 @@ }, { "checksumSHA1": "kaSS4mHWwdHmFfq8jJAWI8rXkVE=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/ian-kent/goose", "path": "github.com/ian-kent/goose", - "revision": "c3541ea826ad9e0f8a4a8c15ca831e8b0adde58c", - "revisionTime": "2014-12-21T09:00:59Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "8a3jdb/e82m61ZwOgB2NbxuTjIc=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/ian-kent/linkio", "path": "github.com/ian-kent/linkio", - "revision": "77fb4b01842cb4b019137c0227df9a8f9779d0bd", - "revisionTime": "2014-12-29T11:24:53Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "L6/CjN/3IdKLxfaBGRPTJ7e62bg=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/jtolds/gls", "path": "github.com/jtolds/gls", - "revision": "bb0351aa7eb6f322f32667d51375f26a2bca6628", - "revisionTime": "2016-12-28T00:43:38Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "ucMoXRa6ccPO5FyBzhey+N+IOsA=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/mailhog/data", "path": "github.com/mailhog/data", - "revision": "024d554958b5bea5db220bfd84922a584d878ded", - "revisionTime": "2017-04-16T19:13:44Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "vyMXU+/pSliAx1yRf6YdKRhF9Ik=", @@ -100,15 +105,17 @@ }, { "checksumSHA1": "eD34ZZL4TFFtDl7tCXMEpp+tDSU=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/mailhog/smtp", "path": "github.com/mailhog/smtp", - "revision": "0c4e9b7e0625fec61d0c30d7b2f6c62852be6c54", - "revisionTime": "2016-11-19T23:01:07Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "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", - "revision": "6d871fb23ecd873cb10cdfc3a8dec5f50d2af8fa", - "revisionTime": "2017-04-16T22:27:39Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "mbhJnsNwGAwkTQH5c2hVRO9YmxA=", @@ -117,40 +124,46 @@ "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", - "revision": "26acb9229f421449ac63d014995b282d59261a8b", - "revisionTime": "2016-12-13T22:48:10Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "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", - "revision": "26acb9229f421449ac63d014995b282d59261a8b", - "revisionTime": "2016-12-13T22:48:10Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "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", - "revision": "26acb9229f421449ac63d014995b282d59261a8b", - "revisionTime": "2016-12-13T22:48:10Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "/mwAihy9AmznMzmbPQ5nWJXBiRU=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey", "path": "github.com/smartystreets/goconvey/convey", - "revision": "3bd662eac601ad6436e64776af2e112069eb2edc", - "revisionTime": "2017-01-10T12:00:22Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "9LakndErFi5uCXtY1KWl0iRnT4c=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey/gotest", "path": "github.com/smartystreets/goconvey/convey/gotest", - "revision": "3bd662eac601ad6436e64776af2e112069eb2edc", - "revisionTime": "2017-01-10T12:00:22Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "FWDhk37bhAwZ2363D/L2xePwR64=", + "origin": "github.com/mailhog/MailHog-Server/vendor/github.com/smartystreets/goconvey/convey/reporting", "path": "github.com/smartystreets/goconvey/convey/reporting", - "revision": "3bd662eac601ad6436e64776af2e112069eb2edc", - "revisionTime": "2017-01-10T12:00:22Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "s0GYwa3YNJJXON/b+6ci2Sz9mEw=", @@ -185,27 +198,31 @@ }, { "checksumSHA1": "o+ZqT87RLprKCGKMboo5vCxdAvA=", + "origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2", "path": "gopkg.in/mgo.v2", - "revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", - "revisionTime": "2016-06-09T18:00:28Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "zTjQOFGy4XTv4L33Kd2FhrV+mbM=", + "origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2/bson", "path": "gopkg.in/mgo.v2/bson", - "revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", - "revisionTime": "2016-06-09T18:00:28Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" }, { "checksumSHA1": "CkCDTsyN2Lbj1cL8+oaYKoPpI9w=", + "origin": "github.com/mailhog/MailHog-Server/vendor/gopkg.in/mgo.v2/internal/sasl", "path": "gopkg.in/mgo.v2/internal/sasl", - "revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", - "revisionTime": "2016-06-09T18:00:28Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "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", - "revision": "29cc868a5ca65f401ff318143f9408d02f4799cc", - "revisionTime": "2016-06-09T18:00:28Z" + "revision": "f4e92215ea51d10910ce817c63749f0bd1d76903", + "revisionTime": "2017-04-16T22:43:02Z" } ], "rootPath": "github.com/mailhog/MailHog"