aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/vendor/github.com/labstack
diff options
context:
space:
mode:
Diffstat (limited to 'src/dma/vendor/github.com/labstack')
-rw-r--r--src/dma/vendor/github.com/labstack/echo/.travis.yml10
-rw-r--r--src/dma/vendor/github.com/labstack/echo/Gopkg.lock75
-rw-r--r--src/dma/vendor/github.com/labstack/echo/Gopkg.toml42
-rw-r--r--src/dma/vendor/github.com/labstack/echo/Makefile14
-rw-r--r--src/dma/vendor/github.com/labstack/echo/README.md2
-rw-r--r--src/dma/vendor/github.com/labstack/echo/bind.go48
-rw-r--r--src/dma/vendor/github.com/labstack/echo/context.go90
-rw-r--r--src/dma/vendor/github.com/labstack/echo/echo.go113
-rw-r--r--src/dma/vendor/github.com/labstack/echo/group.go19
-rw-r--r--src/dma/vendor/github.com/labstack/echo/log.go1
-rw-r--r--src/dma/vendor/github.com/labstack/echo/router.go47
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/LICENSE2
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/log.go2
13 files changed, 190 insertions, 275 deletions
diff --git a/src/dma/vendor/github.com/labstack/echo/.travis.yml b/src/dma/vendor/github.com/labstack/echo/.travis.yml
index 05e53b16..30346d7f 100644
--- a/src/dma/vendor/github.com/labstack/echo/.travis.yml
+++ b/src/dma/vendor/github.com/labstack/echo/.travis.yml
@@ -1,12 +1,14 @@
language: go
go:
- - 1.9.x
- - 1.10.x
+ - 1.11.x
- tip
+env:
+ - GO111MODULE=on
install:
- - make dependency
+ - go get -v golang.org/x/lint/golint
script:
- - make test
+ - golint -set_exit_status ./...
+ - go test -race -coverprofile=coverage.txt -covermode=atomic ./...
after_success:
- bash <(curl -s https://codecov.io/bash)
matrix:
diff --git a/src/dma/vendor/github.com/labstack/echo/Gopkg.lock b/src/dma/vendor/github.com/labstack/echo/Gopkg.lock
deleted file mode 100644
index f3c3b8d2..00000000
--- a/src/dma/vendor/github.com/labstack/echo/Gopkg.lock
+++ /dev/null
@@ -1,75 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
- name = "github.com/davecgh/go-spew"
- packages = ["spew"]
- revision = "346938d642f2ec3594ed81d874461961cd0faa76"
- version = "v1.1.0"
-
-[[projects]]
- name = "github.com/dgrijalva/jwt-go"
- packages = ["."]
- revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e"
- version = "v3.2.0"
-
-[[projects]]
- name = "github.com/labstack/gommon"
- packages = ["bytes","color","log","random"]
- revision = "6fe1405d73ec4bd4cd8a4ac8e2a2b2bf95d03954"
- version = "0.2.4"
-
-[[projects]]
- name = "github.com/mattn/go-colorable"
- packages = ["."]
- revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
- version = "v0.0.9"
-
-[[projects]]
- name = "github.com/mattn/go-isatty"
- packages = ["."]
- revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
- version = "v0.0.3"
-
-[[projects]]
- name = "github.com/pmezard/go-difflib"
- packages = ["difflib"]
- revision = "792786c7400a136282c1664665ae0a8db921c6c2"
- version = "v1.0.0"
-
-[[projects]]
- name = "github.com/stretchr/testify"
- packages = ["assert"]
- revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71"
- version = "v1.2.1"
-
-[[projects]]
- branch = "master"
- name = "github.com/valyala/bytebufferpool"
- packages = ["."]
- revision = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7"
-
-[[projects]]
- branch = "master"
- name = "github.com/valyala/fasttemplate"
- packages = ["."]
- revision = "dcecefd839c4193db0d35b88ec65b4c12d360ab0"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/crypto"
- packages = ["acme","acme/autocert"]
- revision = "182114d582623c1caa54f73de9c7224e23a48487"
-
-[[projects]]
- branch = "master"
- name = "golang.org/x/sys"
- packages = ["unix"]
- revision = "c28acc882ebcbfbe8ce9f0f14b9ac26ee138dd51"
-
-[solve-meta]
- analyzer-name = "dep"
- analyzer-version = 1
- inputs-digest = "9c7b45e80fe353405800cf01f429b3a203cfb8d4468a04c64a908e11a98ea764"
- solver-name = "gps-cdcl"
- solver-version = 1
diff --git a/src/dma/vendor/github.com/labstack/echo/Gopkg.toml b/src/dma/vendor/github.com/labstack/echo/Gopkg.toml
deleted file mode 100644
index 61de60cb..00000000
--- a/src/dma/vendor/github.com/labstack/echo/Gopkg.toml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-# Gopkg.toml example
-#
-# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
-# for detailed Gopkg.toml documentation.
-#
-# required = ["github.com/user/thing/cmd/thing"]
-# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
-#
-# [[constraint]]
-# name = "github.com/user/project"
-# version = "1.0.0"
-#
-# [[constraint]]
-# name = "github.com/user/project2"
-# branch = "dev"
-# source = "github.com/myfork/project2"
-#
-# [[override]]
-# name = "github.com/x/y"
-# version = "2.4.0"
-
-
-[[constraint]]
- name = "github.com/dgrijalva/jwt-go"
- version = "3.2.0"
-
-[[constraint]]
- name = "github.com/labstack/gommon"
- version = "0.2.4"
-
-[[constraint]]
- name = "github.com/stretchr/testify"
- version = "1.2.1"
-
-[[constraint]]
- branch = "master"
- name = "github.com/valyala/fasttemplate"
-
-[[constraint]]
- branch = "master"
- name = "golang.org/x/crypto" \ No newline at end of file
diff --git a/src/dma/vendor/github.com/labstack/echo/Makefile b/src/dma/vendor/github.com/labstack/echo/Makefile
index 494667d8..dfcb6c02 100644
--- a/src/dma/vendor/github.com/labstack/echo/Makefile
+++ b/src/dma/vendor/github.com/labstack/echo/Makefile
@@ -1,17 +1,3 @@
-DEP_VERSION=0.4.1
-
-dependency:
- curl -fsSL -o ${GOPATH}/bin/dep https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64
- chmod +x ${GOPATH}/bin/dep
- dep ensure
-
-test:
- echo "" > coverage.txt
- for d in $(shell go list ./... | grep -v vendor); do \
- go test -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
- [ -f profile.out ] && cat profile.out >> coverage.txt && rm profile.out; \
- done
-
tag:
@git tag `grep -P '^\tversion = ' echo.go|cut -f2 -d'"'`
@git tag|grep -v ^v
diff --git a/src/dma/vendor/github.com/labstack/echo/README.md b/src/dma/vendor/github.com/labstack/echo/README.md
index 0f609df4..49e4d3b1 100644
--- a/src/dma/vendor/github.com/labstack/echo/README.md
+++ b/src/dma/vendor/github.com/labstack/echo/README.md
@@ -32,7 +32,7 @@ Date: 2018/03/15<br>
Source: https://github.com/vishr/web-framework-benchmark<br>
Lower is better!
-<img src="https://api.labstack.com/chart/bar?values=37223,55382,2985,5265|42013,59865,3350,6424&labels=Static,GitHub%20API,Parse%20API,Gplus%20API&titles=Echo,Gin&colors=lightseagreen,goldenrod&x_title=Routes&y_title=ns/op">
+<img src="https://i.imgur.com/I32VdMJ.png">
## [Guide](https://echo.labstack.com/guide)
diff --git a/src/dma/vendor/github.com/labstack/echo/bind.go b/src/dma/vendor/github.com/labstack/echo/bind.go
index 38e07150..4998e25b 100644
--- a/src/dma/vendor/github.com/labstack/echo/bind.go
+++ b/src/dma/vendor/github.com/labstack/echo/bind.go
@@ -31,9 +31,9 @@ type (
func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
req := c.Request()
if req.ContentLength == 0 {
- if req.Method == GET || req.Method == DELETE {
+ if req.Method == http.MethodGet || req.Method == http.MethodDelete {
if err = b.bindData(i, c.QueryParams(), "query"); err != nil {
- return NewHTTPError(http.StatusBadRequest, err.Error())
+ return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
return
}
@@ -44,30 +44,32 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
case strings.HasPrefix(ctype, MIMEApplicationJSON):
if err = json.NewDecoder(req.Body).Decode(i); err != nil {
if ute, ok := err.(*json.UnmarshalTypeError); ok {
- return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unmarshal type error: expected=%v, got=%v, offset=%v", ute.Type, ute.Value, ute.Offset))
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unmarshal type error: expected=%v, got=%v, field=%v, offset=%v", ute.Type, ute.Value, ute.Field, ute.Offset)).SetInternal(err)
} else if se, ok := err.(*json.SyntaxError); ok {
- return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", se.Offset, se.Error()))
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", se.Offset, se.Error())).SetInternal(err)
} else {
- return NewHTTPError(http.StatusBadRequest, err.Error())
+ return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
+ return NewHTTPError(http.StatusBadRequest, err.Error())
}
case strings.HasPrefix(ctype, MIMEApplicationXML), strings.HasPrefix(ctype, MIMETextXML):
if err = xml.NewDecoder(req.Body).Decode(i); err != nil {
if ute, ok := err.(*xml.UnsupportedTypeError); ok {
- return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error()))
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())).SetInternal(err)
} else if se, ok := err.(*xml.SyntaxError); ok {
- return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: line=%v, error=%v", se.Line, se.Error()))
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: line=%v, error=%v", se.Line, se.Error())).SetInternal(err)
} else {
- return NewHTTPError(http.StatusBadRequest, err.Error())
+ return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
+ return NewHTTPError(http.StatusBadRequest, err.Error())
}
case strings.HasPrefix(ctype, MIMEApplicationForm), strings.HasPrefix(ctype, MIMEMultipartForm):
params, err := c.FormParams()
if err != nil {
- return NewHTTPError(http.StatusBadRequest, err.Error())
+ return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
if err = b.bindData(i, params, "form"); err != nil {
- return NewHTTPError(http.StatusBadRequest, err.Error())
+ return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
default:
return ErrUnsupportedMediaType
@@ -96,15 +98,30 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag
inputFieldName = typeField.Name
// If tag is nil, we inspect if the field is a struct.
if _, ok := bindUnmarshaler(structField); !ok && structFieldKind == reflect.Struct {
- err := b.bindData(structField.Addr().Interface(), data, tag)
- if err != nil {
+ if err := b.bindData(structField.Addr().Interface(), data, tag); err != nil {
return err
}
continue
}
}
+
inputValue, exists := data[inputFieldName]
if !exists {
+ // Go json.Unmarshal supports case insensitive binding. However the
+ // url params are bound case sensitive which is inconsistent. To
+ // fix this we must check all of the map values in a
+ // case-insensitive search.
+ inputFieldName = strings.ToLower(inputFieldName)
+ for k, v := range data {
+ if strings.ToLower(k) == inputFieldName {
+ inputValue = v
+ exists = true
+ break
+ }
+ }
+ }
+
+ if !exists {
continue
}
@@ -126,10 +143,9 @@ func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag
}
}
val.Field(i).Set(slice)
- } else {
- if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
- return err
- }
+ } else if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
+ return err
+
}
}
return nil
diff --git a/src/dma/vendor/github.com/labstack/echo/context.go b/src/dma/vendor/github.com/labstack/echo/context.go
index cf780c51..d4722700 100644
--- a/src/dma/vendor/github.com/labstack/echo/context.go
+++ b/src/dma/vendor/github.com/labstack/echo/context.go
@@ -204,6 +204,7 @@ type (
const (
defaultMemory = 32 << 20 // 32 MB
indexPage = "index.html"
+ defaultIndent = " "
)
func (c *context) writeContentType(value string) {
@@ -256,14 +257,13 @@ func (c *context) Scheme() string {
}
func (c *context) RealIP() string {
- ra := c.request.RemoteAddr
if ip := c.request.Header.Get(HeaderXForwardedFor); ip != "" {
- ra = strings.Split(ip, ", ")[0]
- } else if ip := c.request.Header.Get(HeaderXRealIP); ip != "" {
- ra = ip
- } else {
- ra, _, _ = net.SplitHostPort(ra)
+ return strings.Split(ip, ", ")[0]
+ }
+ if ip := c.request.Header.Get(HeaderXRealIP); ip != "" {
+ return ip
}
+ ra, _, _ := net.SplitHostPort(c.request.RemoteAddr)
return ra
}
@@ -404,24 +404,46 @@ func (c *context) String(code int, s string) (err error) {
return c.Blob(code, MIMETextPlainCharsetUTF8, []byte(s))
}
-func (c *context) JSON(code int, i interface{}) (err error) {
+func (c *context) jsonPBlob(code int, callback string, i interface{}) (err error) {
+ enc := json.NewEncoder(c.response)
_, pretty := c.QueryParams()["pretty"]
if c.echo.Debug || pretty {
- return c.JSONPretty(code, i, " ")
+ enc.SetIndent("", " ")
}
- b, err := json.Marshal(i)
- if err != nil {
+ c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8)
+ c.response.WriteHeader(code)
+ if _, err = c.response.Write([]byte(callback + "(")); err != nil {
+ return
+ }
+ if err = enc.Encode(i); err != nil {
+ return
+ }
+ if _, err = c.response.Write([]byte(");")); err != nil {
return
}
- return c.JSONBlob(code, b)
+ return
}
-func (c *context) JSONPretty(code int, i interface{}, indent string) (err error) {
- b, err := json.MarshalIndent(i, "", indent)
- if err != nil {
- return
+func (c *context) json(code int, i interface{}, indent string) error {
+ enc := json.NewEncoder(c.response)
+ if indent != "" {
+ enc.SetIndent("", indent)
+ }
+ c.writeContentType(MIMEApplicationJSONCharsetUTF8)
+ c.response.WriteHeader(code)
+ return enc.Encode(i)
+}
+
+func (c *context) JSON(code int, i interface{}) (err error) {
+ indent := ""
+ if _, pretty := c.QueryParams()["pretty"]; c.echo.Debug || pretty {
+ indent = defaultIndent
}
- return c.JSONBlob(code, b)
+ return c.json(code, i, indent)
+}
+
+func (c *context) JSONPretty(code int, i interface{}, indent string) (err error) {
+ return c.json(code, i, indent)
}
func (c *context) JSONBlob(code int, b []byte) (err error) {
@@ -429,11 +451,7 @@ func (c *context) JSONBlob(code int, b []byte) (err error) {
}
func (c *context) JSONP(code int, callback string, i interface{}) (err error) {
- b, err := json.Marshal(i)
- if err != nil {
- return
- }
- return c.JSONPBlob(code, callback, b)
+ return c.jsonPBlob(code, callback, i)
}
func (c *context) JSONPBlob(code int, callback string, b []byte) (err error) {
@@ -449,24 +467,29 @@ func (c *context) JSONPBlob(code int, callback string, b []byte) (err error) {
return
}
-func (c *context) XML(code int, i interface{}) (err error) {
- _, pretty := c.QueryParams()["pretty"]
- if c.echo.Debug || pretty {
- return c.XMLPretty(code, i, " ")
+func (c *context) xml(code int, i interface{}, indent string) (err error) {
+ c.writeContentType(MIMEApplicationXMLCharsetUTF8)
+ c.response.WriteHeader(code)
+ enc := xml.NewEncoder(c.response)
+ if indent != "" {
+ enc.Indent("", indent)
}
- b, err := xml.Marshal(i)
- if err != nil {
+ if _, err = c.response.Write([]byte(xml.Header)); err != nil {
return
}
- return c.XMLBlob(code, b)
+ return enc.Encode(i)
}
-func (c *context) XMLPretty(code int, i interface{}, indent string) (err error) {
- b, err := xml.MarshalIndent(i, "", indent)
- if err != nil {
- return
+func (c *context) XML(code int, i interface{}) (err error) {
+ indent := ""
+ if _, pretty := c.QueryParams()["pretty"]; c.echo.Debug || pretty {
+ indent = defaultIndent
}
- return c.XMLBlob(code, b)
+ return c.xml(code, i, indent)
+}
+
+func (c *context) XMLPretty(code int, i interface{}, indent string) (err error) {
+ return c.xml(code, i, indent)
}
func (c *context) XMLBlob(code int, b []byte) (err error) {
@@ -574,3 +597,4 @@ func (c *context) Reset(r *http.Request, w http.ResponseWriter) {
// NOTE: Don't reset because it has to have length c.echo.maxParam at all times
// c.pvalues = nil
}
+
diff --git a/src/dma/vendor/github.com/labstack/echo/echo.go b/src/dma/vendor/github.com/labstack/echo/echo.go
index 41ac6b5e..98286515 100644
--- a/src/dma/vendor/github.com/labstack/echo/echo.go
+++ b/src/dma/vendor/github.com/labstack/echo/echo.go
@@ -62,7 +62,7 @@ import (
type (
// Echo is the top-level framework instance.
Echo struct {
- stdLogger *stdLog.Logger
+ StdLogger *stdLog.Logger
colorer *color.Color
premiddleware []MiddlewareFunc
middleware []MiddlewareFunc
@@ -103,7 +103,7 @@ type (
// MiddlewareFunc defines a function to process middleware.
MiddlewareFunc func(HandlerFunc) HandlerFunc
- // HandlerFunc defines a function to server HTTP requests.
+ // HandlerFunc defines a function to serve HTTP requests.
HandlerFunc func(Context) error
// HTTPErrorHandler is a centralized HTTP error handler.
@@ -129,17 +129,18 @@ type (
)
// HTTP methods
+// NOTE: Deprecated, please use the stdlib constants directly instead.
const (
- CONNECT = "CONNECT"
- DELETE = "DELETE"
- GET = "GET"
- HEAD = "HEAD"
- OPTIONS = "OPTIONS"
- PATCH = "PATCH"
- POST = "POST"
- PROPFIND = "PROPFIND"
- PUT = "PUT"
- TRACE = "TRACE"
+ CONNECT = http.MethodConnect
+ DELETE = http.MethodDelete
+ GET = http.MethodGet
+ HEAD = http.MethodHead
+ OPTIONS = http.MethodOptions
+ PATCH = http.MethodPatch
+ POST = http.MethodPost
+ // PROPFIND = "PROPFIND"
+ PUT = http.MethodPut
+ TRACE = http.MethodTrace
)
// MIME types
@@ -165,6 +166,8 @@ const (
const (
charsetUTF8 = "charset=UTF-8"
+ // PROPFIND Method can be used on collection and property resources.
+ PROPFIND = "PROPFIND"
)
// Headers
@@ -217,7 +220,8 @@ const (
)
const (
- Version = "3.3.5"
+ // Version of Echo
+ Version = "3.3.10-dev"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
@@ -234,16 +238,16 @@ ____________________________________O/_______
var (
methods = [...]string{
- CONNECT,
- DELETE,
- GET,
- HEAD,
- OPTIONS,
- PATCH,
- POST,
+ http.MethodConnect,
+ http.MethodDelete,
+ http.MethodGet,
+ http.MethodHead,
+ http.MethodOptions,
+ http.MethodPatch,
+ http.MethodPost,
PROPFIND,
- PUT,
- TRACE,
+ http.MethodPut,
+ http.MethodTrace,
}
)
@@ -255,6 +259,12 @@ var (
ErrForbidden = NewHTTPError(http.StatusForbidden)
ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed)
ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge)
+ ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests)
+ ErrBadRequest = NewHTTPError(http.StatusBadRequest)
+ ErrBadGateway = NewHTTPError(http.StatusBadGateway)
+ ErrInternalServerError = NewHTTPError(http.StatusInternalServerError)
+ ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout)
+ ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable)
ErrValidatorNotRegistered = errors.New("validator not registered")
ErrRendererNotRegistered = errors.New("renderer not registered")
ErrInvalidRedirectCode = errors.New("invalid redirect status code")
@@ -289,7 +299,7 @@ func New() (e *Echo) {
e.HTTPErrorHandler = e.DefaultHTTPErrorHandler
e.Binder = &DefaultBinder{}
e.Logger.SetLevel(log.ERROR)
- e.stdLogger = stdLog.New(e.Logger.Output(), e.Logger.Prefix()+": ", 0)
+ e.StdLogger = stdLog.New(e.Logger.Output(), e.Logger.Prefix()+": ", 0)
e.pool.New = func() interface{} {
return e.NewContext(nil, nil)
}
@@ -326,7 +336,7 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
code = he.Code
msg = he.Message
if he.Internal != nil {
- msg = fmt.Sprintf("%v, %v", err, he.Internal)
+ err = fmt.Errorf("%v, %v", err, he.Internal)
}
} else if e.Debug {
msg = err.Error()
@@ -337,11 +347,9 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
msg = Map{"message": msg}
}
- e.Logger.Error(err)
-
// Send response
if !c.Response().Committed {
- if c.Request().Method == HEAD { // Issue #608
+ if c.Request().Method == http.MethodHead { // Issue #608
err = c.NoContent(code)
} else {
err = c.JSON(code, msg)
@@ -365,55 +373,55 @@ func (e *Echo) Use(middleware ...MiddlewareFunc) {
// CONNECT registers a new CONNECT route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(CONNECT, path, h, m...)
+ return e.Add(http.MethodConnect, path, h, m...)
}
// DELETE registers a new DELETE route for a path with matching handler in the router
// with optional route-level middleware.
func (e *Echo) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(DELETE, path, h, m...)
+ return e.Add(http.MethodDelete, path, h, m...)
}
// GET registers a new GET route for a path with matching handler in the router
// with optional route-level middleware.
func (e *Echo) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(GET, path, h, m...)
+ return e.Add(http.MethodGet, path, h, m...)
}
// HEAD registers a new HEAD route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(HEAD, path, h, m...)
+ return e.Add(http.MethodHead, path, h, m...)
}
// OPTIONS registers a new OPTIONS route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(OPTIONS, path, h, m...)
+ return e.Add(http.MethodOptions, path, h, m...)
}
// PATCH registers a new PATCH route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(PATCH, path, h, m...)
+ return e.Add(http.MethodPatch, path, h, m...)
}
// POST registers a new POST route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(POST, path, h, m...)
+ return e.Add(http.MethodPost, path, h, m...)
}
// PUT registers a new PUT route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(PUT, path, h, m...)
+ return e.Add(http.MethodPut, path, h, m...)
}
// TRACE registers a new TRACE route for a path with matching handler in the
// router with optional route-level middleware.
func (e *Echo) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(TRACE, path, h, m...)
+ return e.Add(http.MethodTrace, path, h, m...)
}
// Any registers a new route for all HTTP methods and path with matching handler
@@ -462,11 +470,11 @@ func static(i i, prefix, root string) *Route {
return i.GET(prefix+"/*", h)
}
-// File registers a new route with path to serve a static file.
-func (e *Echo) File(path, file string) *Route {
+// File registers a new route with path to serve a static file with optional route-level middleware.
+func (e *Echo) File(path, file string, m ...MiddlewareFunc) *Route {
return e.GET(path, func(c Context) error {
return c.File(file)
- })
+ }, m...)
}
// Add registers a new route for an HTTP method and path with matching handler
@@ -559,26 +567,17 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c := e.pool.Get().(*context)
c.Reset(r, w)
- m := r.Method
h := NotFoundHandler
if e.premiddleware == nil {
- path := r.URL.RawPath
- if path == "" {
- path = r.URL.Path
- }
- e.router.Find(m, getPath(r), c)
+ e.router.Find(r.Method, getPath(r), c)
h = c.Handler()
for i := len(e.middleware) - 1; i >= 0; i-- {
h = e.middleware[i](h)
}
} else {
h = func(c Context) error {
- path := r.URL.RawPath
- if path == "" {
- path = r.URL.Path
- }
- e.router.Find(m, getPath(r), c)
+ e.router.Find(r.Method, getPath(r), c)
h := c.Handler()
for i := len(e.middleware) - 1; i >= 0; i-- {
h = e.middleware[i](h)
@@ -622,10 +621,6 @@ func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
// StartAutoTLS starts an HTTPS server using certificates automatically installed from https://letsencrypt.org.
func (e *Echo) StartAutoTLS(address string) error {
- if e.Listener == nil {
- go http.ListenAndServe(":http", e.AutoTLSManager.HTTPHandler(nil))
- }
-
s := e.TLSServer
s.TLSConfig = new(tls.Config)
s.TLSConfig.GetCertificate = e.AutoTLSManager.GetCertificate
@@ -645,7 +640,7 @@ func (e *Echo) startTLS(address string) error {
func (e *Echo) StartServer(s *http.Server) (err error) {
// Setup
e.colorer.SetOutput(e.Logger.Output())
- s.ErrorLog = e.stdLogger
+ s.ErrorLog = e.StdLogger
s.Handler = e
if e.Debug {
e.Logger.SetLevel(log.DEBUG)
@@ -689,7 +684,7 @@ func (e *Echo) Close() error {
return e.Server.Close()
}
-// Shutdown stops server the gracefully.
+// Shutdown stops the server gracefully.
// It internally calls `http.Server#Shutdown()`.
func (e *Echo) Shutdown(ctx stdContext.Context) error {
if err := e.TLSServer.Shutdown(ctx); err != nil {
@@ -712,6 +707,12 @@ func (he *HTTPError) Error() string {
return fmt.Sprintf("code=%d, message=%v", he.Code, he.Message)
}
+// SetInternal sets error to HTTPError.Internal
+func (he *HTTPError) SetInternal(err error) *HTTPError {
+ he.Internal = err
+ return he
+}
+
// WrapHandler wraps `http.Handler` into `echo.HandlerFunc`.
func WrapHandler(h http.Handler) HandlerFunc {
return func(c Context) error {
diff --git a/src/dma/vendor/github.com/labstack/echo/group.go b/src/dma/vendor/github.com/labstack/echo/group.go
index 5257e83c..3e3732b6 100644
--- a/src/dma/vendor/github.com/labstack/echo/group.go
+++ b/src/dma/vendor/github.com/labstack/echo/group.go
@@ -1,6 +1,7 @@
package echo
import (
+ "net/http"
"path"
)
@@ -29,47 +30,47 @@ func (g *Group) Use(middleware ...MiddlewareFunc) {
// CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.
func (g *Group) CONNECT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(CONNECT, path, h, m...)
+ return g.Add(http.MethodConnect, path, h, m...)
}
// DELETE implements `Echo#DELETE()` for sub-routes within the Group.
func (g *Group) DELETE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(DELETE, path, h, m...)
+ return g.Add(http.MethodDelete, path, h, m...)
}
// GET implements `Echo#GET()` for sub-routes within the Group.
func (g *Group) GET(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(GET, path, h, m...)
+ return g.Add(http.MethodGet, path, h, m...)
}
// HEAD implements `Echo#HEAD()` for sub-routes within the Group.
func (g *Group) HEAD(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(HEAD, path, h, m...)
+ return g.Add(http.MethodHead, path, h, m...)
}
// OPTIONS implements `Echo#OPTIONS()` for sub-routes within the Group.
func (g *Group) OPTIONS(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(OPTIONS, path, h, m...)
+ return g.Add(http.MethodOptions, path, h, m...)
}
// PATCH implements `Echo#PATCH()` for sub-routes within the Group.
func (g *Group) PATCH(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(PATCH, path, h, m...)
+ return g.Add(http.MethodPatch, path, h, m...)
}
// POST implements `Echo#POST()` for sub-routes within the Group.
func (g *Group) POST(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(POST, path, h, m...)
+ return g.Add(http.MethodPost, path, h, m...)
}
// PUT implements `Echo#PUT()` for sub-routes within the Group.
func (g *Group) PUT(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(PUT, path, h, m...)
+ return g.Add(http.MethodPut, path, h, m...)
}
// TRACE implements `Echo#TRACE()` for sub-routes within the Group.
func (g *Group) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(TRACE, path, h, m...)
+ return g.Add(http.MethodTrace, path, h, m...)
}
// Any implements `Echo#Any()` for sub-routes within the Group.
diff --git a/src/dma/vendor/github.com/labstack/echo/log.go b/src/dma/vendor/github.com/labstack/echo/log.go
index b194c39c..3f8de590 100644
--- a/src/dma/vendor/github.com/labstack/echo/log.go
+++ b/src/dma/vendor/github.com/labstack/echo/log.go
@@ -15,6 +15,7 @@ type (
SetPrefix(p string)
Level() log.Lvl
SetLevel(v log.Lvl)
+ SetHeader(h string)
Print(i ...interface{})
Printf(format string, args ...interface{})
Printj(j log.JSON)
diff --git a/src/dma/vendor/github.com/labstack/echo/router.go b/src/dma/vendor/github.com/labstack/echo/router.go
index ff53da87..73f0b68b 100644
--- a/src/dma/vendor/github.com/labstack/echo/router.go
+++ b/src/dma/vendor/github.com/labstack/echo/router.go
@@ -1,5 +1,7 @@
package echo
+import "net/http"
+
type (
// Router is the registry of all registered routes for an `Echo` instance for
// request matching and URL path parameter parsing.
@@ -79,7 +81,7 @@ func (r *Router) Add(method, path string, h HandlerFunc) {
r.insert(method, path[:i], h, pkind, ppath, pnames)
return
}
- r.insert(method, path[:i], nil, pkind, ppath, pnames)
+ r.insert(method, path[:i], nil, pkind, "", nil)
} else if path[i] == '*' {
r.insert(method, path[:i], nil, skind, "", nil)
pnames = append(pnames, "*")
@@ -226,50 +228,50 @@ func (n *node) findChildByKind(t kind) *node {
func (n *node) addHandler(method string, h HandlerFunc) {
switch method {
- case CONNECT:
+ case http.MethodConnect:
n.methodHandler.connect = h
- case DELETE:
+ case http.MethodDelete:
n.methodHandler.delete = h
- case GET:
+ case http.MethodGet:
n.methodHandler.get = h
- case HEAD:
+ case http.MethodHead:
n.methodHandler.head = h
- case OPTIONS:
+ case http.MethodOptions:
n.methodHandler.options = h
- case PATCH:
+ case http.MethodPatch:
n.methodHandler.patch = h
- case POST:
+ case http.MethodPost:
n.methodHandler.post = h
case PROPFIND:
n.methodHandler.propfind = h
- case PUT:
+ case http.MethodPut:
n.methodHandler.put = h
- case TRACE:
+ case http.MethodTrace:
n.methodHandler.trace = h
}
}
func (n *node) findHandler(method string) HandlerFunc {
switch method {
- case CONNECT:
+ case http.MethodConnect:
return n.methodHandler.connect
- case DELETE:
+ case http.MethodDelete:
return n.methodHandler.delete
- case GET:
+ case http.MethodGet:
return n.methodHandler.get
- case HEAD:
+ case http.MethodHead:
return n.methodHandler.head
- case OPTIONS:
+ case http.MethodOptions:
return n.methodHandler.options
- case PATCH:
+ case http.MethodPatch:
return n.methodHandler.patch
- case POST:
+ case http.MethodPost:
return n.methodHandler.post
case PROPFIND:
return n.methodHandler.propfind
- case PUT:
+ case http.MethodPut:
return n.methodHandler.put
- case TRACE:
+ case http.MethodTrace:
return n.methodHandler.trace
default:
return nil
@@ -311,7 +313,7 @@ func (r *Router) Find(method, path string, c Context) {
// Search order static > param > any
for {
if search == "" {
- goto End
+ break
}
pl := 0 // Prefix length
@@ -346,7 +348,7 @@ func (r *Router) Find(method, path string, c Context) {
}
if search == "" {
- goto End
+ break
}
// Static node
@@ -403,10 +405,9 @@ func (r *Router) Find(method, path string, c Context) {
return
}
pvalues[len(cn.pnames)-1] = search
- goto End
+ break
}
-End:
ctx.handler = cn.findHandler(method)
ctx.path = cn.ppath
ctx.pnames = cn.pnames
diff --git a/src/dma/vendor/github.com/labstack/gommon/LICENSE b/src/dma/vendor/github.com/labstack/gommon/LICENSE
index d2ae3edf..fc718faf 100644
--- a/src/dma/vendor/github.com/labstack/gommon/LICENSE
+++ b/src/dma/vendor/github.com/labstack/gommon/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015 labstack
+Copyright (c) 2018 labstack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/log.go b/src/dma/vendor/github.com/labstack/gommon/log/log.go
index 0d77a87a..132411db 100644
--- a/src/dma/vendor/github.com/labstack/gommon/log/log.go
+++ b/src/dma/vendor/github.com/labstack/gommon/log/log.go
@@ -219,7 +219,7 @@ func (l *Logger) Panic(i ...interface{}) {
func (l *Logger) Panicf(format string, args ...interface{}) {
l.log(panicLevel, format, args...)
- panic(fmt.Sprintf(format, args))
+ panic(fmt.Sprintf(format, args...))
}
func (l *Logger) Panicj(j JSON) {