Browse Source

vendor: update gopkg.in/macaron.v1

pull/4940/merge
Unknwon 7 years ago
parent
commit
b9e4a052b8
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      gogs.go
  2. 2
      templates/.VERSION
  3. 2
      vendor/gopkg.in/macaron.v1/LICENSE
  4. 6
      vendor/gopkg.in/macaron.v1/README.md
  5. 5
      vendor/gopkg.in/macaron.v1/context.go
  6. 4
      vendor/gopkg.in/macaron.v1/macaron.go
  7. 13
      vendor/gopkg.in/macaron.v1/response_writer.go
  8. 16
      vendor/gopkg.in/macaron.v1/router.go
  9. 33
      vendor/gopkg.in/macaron.v1/tree.go
  10. 25
      vendor/gopkg.in/macaron.v1/util_go17.go
  11. 24
      vendor/gopkg.in/macaron.v1/util_go18.go
  12. 6
      vendor/vendor.json

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const APP_VER = "0.11.34.0302" const APP_VER = "0.11.35.0306"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

2
templates/.VERSION

@ -1 +1 @@
0.11.34.0302 0.11.35.0306

2
vendor/gopkg.in/macaron.v1/LICENSE generated vendored

@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within the same "printed page" as the copyright notice for easier identification within
third-party archives. third-party archives.
Copyright [yyyy] [name of copyright owner] Copyright 2014 The Macaron Authors
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

6
vendor/gopkg.in/macaron.v1/README.md generated vendored

@ -61,19 +61,20 @@ There are already many [middlewares](https://github.com/go-macaron) to simplify
- [bindata](https://github.com/go-macaron/bindata) - Embed binary data as static and template files - [bindata](https://github.com/go-macaron/bindata) - Embed binary data as static and template files
- [toolbox](https://github.com/go-macaron/toolbox) - Health check, pprof, profile and statistic services - [toolbox](https://github.com/go-macaron/toolbox) - Health check, pprof, profile and statistic services
- [oauth2](https://github.com/go-macaron/oauth2) - OAuth 2.0 backend - [oauth2](https://github.com/go-macaron/oauth2) - OAuth 2.0 backend
- [authz](https://github.com/go-macaron/authz) - ACL/RBAC/ABAC authorization based on Casbin
- [switcher](https://github.com/go-macaron/switcher) - Multiple-site support - [switcher](https://github.com/go-macaron/switcher) - Multiple-site support
- [method](https://github.com/go-macaron/method) - HTTP method override - [method](https://github.com/go-macaron/method) - HTTP method override
- [permissions2](https://github.com/xyproto/permissions2) - Cookies, users and permissions - [permissions2](https://github.com/xyproto/permissions2) - Cookies, users and permissions
- [renders](https://github.com/go-macaron/renders) - Beego-like render engine(Macaron has built-in template engine, this is another option) - [renders](https://github.com/go-macaron/renders) - Beego-like render engine(Macaron has built-in template engine, this is another option)
- [piwik](https://github.com/veecue/piwik-middleware) - Server-side piwik analytics
## Use Cases ## Use Cases
- [Gogs](https://gogs.io): A painless self-hosted Git Service - [Gogs](https://gogs.io): A painless self-hosted Git Service
- [Grafana](http://grafana.org/): The tool for beautiful monitoring and metric analytics & dashboards - [Grafana](http://grafana.org/): The open platform for beautiful analytics and monitoring
- [Peach](https://peachdocs.org): A modern web documentation server - [Peach](https://peachdocs.org): A modern web documentation server
- [Go Walker](https://gowalker.org): Go online API documentation - [Go Walker](https://gowalker.org): Go online API documentation
- [Switch](https://gopm.io): Gopm registry - [Switch](https://gopm.io): Gopm registry
- [YouGam](http://yougam.com): Online Forum
- [Critical Stack Intel](https://intel.criticalstack.com/): A 100% free intel marketplace from Critical Stack, Inc. - [Critical Stack Intel](https://intel.criticalstack.com/): A 100% free intel marketplace from Critical Stack, Inc.
## Getting Help ## Getting Help
@ -81,7 +82,6 @@ There are already many [middlewares](https://github.com/go-macaron) to simplify
- [API Reference](https://gowalker.org/gopkg.in/macaron.v1) - [API Reference](https://gowalker.org/gopkg.in/macaron.v1)
- [Documentation](https://go-macaron.com) - [Documentation](https://go-macaron.com)
- [FAQs](https://go-macaron.com/docs/faqs) - [FAQs](https://go-macaron.com/docs/faqs)
- [![Join the chat at https://gitter.im/Unknwon/macaron](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-macaron/macaron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Credits ## Credits

5
vendor/gopkg.in/macaron.v1/context.go generated vendored

@ -268,6 +268,11 @@ func (ctx *Context) SetParams(name, val string) {
ctx.params[name] = val ctx.params[name] = val
} }
// ReplaceAllParams replace all current params with given params
func (ctx *Context) ReplaceAllParams(params Params) {
ctx.params = params;
}
// ParamsEscape returns escapred params result. // ParamsEscape returns escapred params result.
// e.g. ctx.ParamsEscape(":uname") // e.g. ctx.ParamsEscape(":uname")
func (ctx *Context) ParamsEscape(name string) string { func (ctx *Context) ParamsEscape(name string) string {

4
vendor/gopkg.in/macaron.v1/macaron.go generated vendored

@ -32,7 +32,7 @@ import (
"github.com/go-macaron/inject" "github.com/go-macaron/inject"
) )
const _VERSION = "1.2.1.0219" const _VERSION = "1.3.1.0306"
func Version() string { func Version() string {
return _VERSION return _VERSION
@ -194,7 +194,7 @@ func (m *Macaron) createContext(rw http.ResponseWriter, req *http.Request) *Cont
index: 0, index: 0,
Router: m.Router, Router: m.Router,
Req: Request{req}, Req: Request{req},
Resp: NewResponseWriter(rw), Resp: NewResponseWriter(req.Method, rw),
Render: &DummyRender{rw}, Render: &DummyRender{rw},
Data: make(map[string]interface{}), Data: make(map[string]interface{}),
} }

13
vendor/gopkg.in/macaron.v1/response_writer.go generated vendored

@ -42,11 +42,12 @@ type ResponseWriter interface {
type BeforeFunc func(ResponseWriter) type BeforeFunc func(ResponseWriter)
// NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter // NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter { func NewResponseWriter(method string, rw http.ResponseWriter) ResponseWriter {
return &responseWriter{rw, 0, 0, nil} return &responseWriter{method, rw, 0, 0, nil}
} }
type responseWriter struct { type responseWriter struct {
method string
http.ResponseWriter http.ResponseWriter
status int status int
size int size int
@ -59,13 +60,15 @@ func (rw *responseWriter) WriteHeader(s int) {
rw.status = s rw.status = s
} }
func (rw *responseWriter) Write(b []byte) (int, error) { func (rw *responseWriter) Write(b []byte) (size int, err error) {
if !rw.Written() { if !rw.Written() {
// The status will be StatusOK if WriteHeader has not been called yet // The status will be StatusOK if WriteHeader has not been called yet
rw.WriteHeader(http.StatusOK) rw.WriteHeader(http.StatusOK)
} }
size, err := rw.ResponseWriter.Write(b) if rw.method != "HEAD" {
rw.size += size size, err = rw.ResponseWriter.Write(b)
rw.size += size
}
return size, err return size, err
} }

16
vendor/gopkg.in/macaron.v1/router.go generated vendored

@ -96,7 +96,7 @@ func NewRouter() *Router {
} }
// SetAutoHead sets the value who determines whether add HEAD method automatically // SetAutoHead sets the value who determines whether add HEAD method automatically
// when GET method is added. Combo router will not be affected by this value. // when GET method is added.
func (r *Router) SetAutoHead(v bool) { func (r *Router) SetAutoHead(v bool) {
r.autoHead = v r.autoHead = v
} }
@ -118,7 +118,7 @@ func (r *Route) Name(name string) {
if len(name) == 0 { if len(name) == 0 {
panic("route name cannot be empty") panic("route name cannot be empty")
} else if r.router.namedRoutes[name] != nil { } else if r.router.namedRoutes[name] != nil {
panic("route with given name already exists") panic("route with given name already exists: " + name)
} }
r.router.namedRoutes[name] = r.leaf r.router.namedRoutes[name] = r.leaf
} }
@ -288,7 +288,14 @@ func (r *Router) SetHandlerWrapper(f func(Handler) Handler) {
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) { func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if t, ok := r.routers[req.Method]; ok { if t, ok := r.routers[req.Method]; ok {
h, p, ok := t.Match(req.URL.Path) // Fast match for static routes
leaf := r.getLeaf(req.Method, req.URL.Path)
if leaf != nil {
leaf.handle(rw, req, nil)
return
}
h, p, ok := t.Match(req.URL.EscapedPath())
if ok { if ok {
if splat, ok := p["*0"]; ok { if splat, ok := p["*0"]; ok {
p["*"] = splat // Easy name. p["*"] = splat // Easy name.
@ -334,6 +341,9 @@ func (cr *ComboRouter) route(fn func(string, ...Handler) *Route, method string,
} }
func (cr *ComboRouter) Get(h ...Handler) *ComboRouter { func (cr *ComboRouter) Get(h ...Handler) *ComboRouter {
if cr.router.autoHead {
cr.Head(h...)
}
return cr.route(cr.router.Get, "GET", h...) return cr.route(cr.router.Get, "GET", h...)
} }

33
vendor/gopkg.in/macaron.v1/tree.go generated vendored

@ -261,6 +261,10 @@ func (t *Tree) Add(pattern string, handle Handle) *Leaf {
} }
func (t *Tree) matchLeaf(globLevel int, url string, params Params) (Handle, bool) { func (t *Tree) matchLeaf(globLevel int, url string, params Params) (Handle, bool) {
url, err := PathUnescape(url)
if err != nil {
return nil, false
}
for i := 0; i < len(t.leaves); i++ { for i := 0; i < len(t.leaves); i++ {
switch t.leaves[i].typ { switch t.leaves[i].typ {
case _PATTERN_STATIC: case _PATTERN_STATIC:
@ -300,16 +304,20 @@ func (t *Tree) matchLeaf(globLevel int, url string, params Params) (Handle, bool
} }
func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) (Handle, bool) { func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) (Handle, bool) {
unescapedSegment, err := PathUnescape(segment)
if err != nil {
return nil, false
}
for i := 0; i < len(t.subtrees); i++ { for i := 0; i < len(t.subtrees); i++ {
switch t.subtrees[i].typ { switch t.subtrees[i].typ {
case _PATTERN_STATIC: case _PATTERN_STATIC:
if t.subtrees[i].pattern == segment { if t.subtrees[i].pattern == unescapedSegment {
if handle, ok := t.subtrees[i].matchNextSegment(globLevel, url, params); ok { if handle, ok := t.subtrees[i].matchNextSegment(globLevel, url, params); ok {
return handle, true return handle, true
} }
} }
case _PATTERN_REGEXP: case _PATTERN_REGEXP:
results := t.subtrees[i].reg.FindStringSubmatch(segment) results := t.subtrees[i].reg.FindStringSubmatch(unescapedSegment)
if len(results)-1 != len(t.subtrees[i].wildcards) { if len(results)-1 != len(t.subtrees[i].wildcards) {
break break
} }
@ -322,12 +330,12 @@ func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) (
} }
case _PATTERN_HOLDER: case _PATTERN_HOLDER:
if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok { if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok {
params[t.subtrees[i].wildcards[0]] = segment params[t.subtrees[i].wildcards[0]] = unescapedSegment
return handle, true return handle, true
} }
case _PATTERN_MATCH_ALL: case _PATTERN_MATCH_ALL:
if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok { if handle, ok := t.subtrees[i].matchNextSegment(globLevel+1, url, params); ok {
params["*"+com.ToStr(globLevel)] = segment params["*"+com.ToStr(globLevel)] = unescapedSegment
return handle, true return handle, true
} }
} }
@ -335,19 +343,22 @@ func (t *Tree) matchSubtree(globLevel int, segment, url string, params Params) (
if len(t.leaves) > 0 { if len(t.leaves) > 0 {
leaf := t.leaves[len(t.leaves)-1] leaf := t.leaves[len(t.leaves)-1]
unescapedURL, err := PathUnescape(segment + "/" + url)
if err != nil {
return nil, false
}
if leaf.typ == _PATTERN_PATH_EXT { if leaf.typ == _PATTERN_PATH_EXT {
url = segment + "/" + url j := strings.LastIndex(unescapedURL, ".")
j := strings.LastIndex(url, ".")
if j > -1 { if j > -1 {
params[":path"] = url[:j] params[":path"] = unescapedURL[:j]
params[":ext"] = url[j+1:] params[":ext"] = unescapedURL[j+1:]
} else { } else {
params[":path"] = url params[":path"] = unescapedURL
} }
return leaf.handle, true return leaf.handle, true
} else if leaf.typ == _PATTERN_MATCH_ALL { } else if leaf.typ == _PATTERN_MATCH_ALL {
params["*"] = segment + "/" + url params["*"] = unescapedURL
params["*"+com.ToStr(globLevel)] = segment + "/" + url params["*"+com.ToStr(globLevel)] = unescapedURL
return leaf.handle, true return leaf.handle, true
} }
} }

25
vendor/gopkg.in/macaron.v1/util_go17.go generated vendored

@ -0,0 +1,25 @@
// +build !go1.8
// Copyright 2017 The Macaron Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import "net/url"
// PathUnescape unescapes a path. Ideally, this function would use
// url.PathUnescape(..), but the function was not introduced until go1.8.
func PathUnescape(s string) (string, error) {
return url.QueryUnescape(s)
}

24
vendor/gopkg.in/macaron.v1/util_go18.go generated vendored

@ -0,0 +1,24 @@
// +build go1.8
// Copyright 2017 The Macaron Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import "net/url"
// PathUnescape unescapes a path.
func PathUnescape(s string) (string, error) {
return url.PathUnescape(s)
}

6
vendor/vendor.json vendored

@ -597,10 +597,10 @@
"revisionTime": "2016-08-08T14:54:09Z" "revisionTime": "2016-08-08T14:54:09Z"
}, },
{ {
"checksumSHA1": "qM9ubEa57g4oNa6JLFQ+e1TCMno=", "checksumSHA1": "7c6yCe2PjyV+/qWiPBWUf+j+1us=",
"path": "gopkg.in/macaron.v1", "path": "gopkg.in/macaron.v1",
"revision": "a325110f8b392bce3e5cdeb8c44bf98078ada3be", "revision": "c1be95e6d21e769e44e1ec33cec9da5837861c10",
"revisionTime": "2017-02-19T20:49:11Z" "revisionTime": "2018-03-06T06:20:08Z"
}, },
{ {
"checksumSHA1": "6QPjE+qflEBHg+JPJd9e4iQuRAk=", "checksumSHA1": "6QPjE+qflEBHg+JPJd9e4iQuRAk=",

Loading…
Cancel
Save