aboutsummaryrefslogtreecommitdiffstats
path: root/src/dma/vendor/github.com/labstack
diff options
context:
space:
mode:
authorToshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>2018-09-06 09:04:29 +0000
committerToshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>2018-09-07 06:03:01 +0000
commitd61931341176dad9ccff7c967a10d88fe54218fa (patch)
tree526457882d4abe0c38d2242d6daa311bf8ef51cf /src/dma/vendor/github.com/labstack
parent73abc060f31a6bf866fa1dad0a1a6efdfd94d775 (diff)
src: Add DMA localagent
Change-Id: Ibcee814fbc9a904448eeb368a1a26bbb69cf54aa Signed-off-by: Toshiaki Takahashi <takahashi.tsc@ncos.nec.co.jp>
Diffstat (limited to 'src/dma/vendor/github.com/labstack')
-rw-r--r--src/dma/vendor/github.com/labstack/echo/.editorconfig25
-rw-r--r--src/dma/vendor/github.com/labstack/echo/.gitattributes20
-rw-r--r--src/dma/vendor/github.com/labstack/echo/.gitignore7
-rw-r--r--src/dma/vendor/github.com/labstack/echo/.travis.yml14
-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/LICENSE21
-rw-r--r--src/dma/vendor/github.com/labstack/echo/Makefile17
-rw-r--r--src/dma/vendor/github.com/labstack/echo/README.md99
-rw-r--r--src/dma/vendor/github.com/labstack/echo/bind.go261
-rw-r--r--src/dma/vendor/github.com/labstack/echo/context.go576
-rw-r--r--src/dma/vendor/github.com/labstack/echo/echo.go781
-rw-r--r--src/dma/vendor/github.com/labstack/echo/group.go120
-rw-r--r--src/dma/vendor/github.com/labstack/echo/log.go40
-rw-r--r--src/dma/vendor/github.com/labstack/echo/response.go110
-rw-r--r--src/dma/vendor/github.com/labstack/echo/router.go434
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/LICENSE22
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/color/README.md86
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/color/color.go407
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/README.md5
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/color.go13
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/log.go415
-rw-r--r--src/dma/vendor/github.com/labstack/gommon/log/white.go12
23 files changed, 3602 insertions, 0 deletions
diff --git a/src/dma/vendor/github.com/labstack/echo/.editorconfig b/src/dma/vendor/github.com/labstack/echo/.editorconfig
new file mode 100644
index 00000000..17ae50dd
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/.editorconfig
@@ -0,0 +1,25 @@
+# EditorConfig coding styles definitions. For more information about the
+# properties used in this file, please see the EditorConfig documentation:
+# http://editorconfig.org/
+
+# indicate this is the root of the project
+root = true
+
+[*]
+charset = utf-8
+
+end_of_line = LF
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+indent_style = space
+indent_size = 2
+
+[Makefile]
+indent_style = tab
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.go]
+indent_style = tab
diff --git a/src/dma/vendor/github.com/labstack/echo/.gitattributes b/src/dma/vendor/github.com/labstack/echo/.gitattributes
new file mode 100644
index 00000000..49b63e52
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/.gitattributes
@@ -0,0 +1,20 @@
+# Automatically normalize line endings for all text-based files
+# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
+* text=auto
+
+# For the following file types, normalize line endings to LF on checking and
+# prevent conversion to CRLF when they are checked out (this is required in
+# order to prevent newline related issues)
+.* text eol=lf
+*.go text eol=lf
+*.yml text eol=lf
+*.html text eol=lf
+*.css text eol=lf
+*.js text eol=lf
+*.json text eol=lf
+LICENSE text eol=lf
+
+# Exclude `website` and `cookbook` from GitHub's language statistics
+# https://github.com/github/linguist#using-gitattributes
+cookbook/* linguist-documentation
+website/* linguist-documentation
diff --git a/src/dma/vendor/github.com/labstack/echo/.gitignore b/src/dma/vendor/github.com/labstack/echo/.gitignore
new file mode 100644
index 00000000..dd74acca
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/.gitignore
@@ -0,0 +1,7 @@
+.DS_Store
+coverage.txt
+_test
+vendor
+.idea
+*.iml
+*.out
diff --git a/src/dma/vendor/github.com/labstack/echo/.travis.yml b/src/dma/vendor/github.com/labstack/echo/.travis.yml
new file mode 100644
index 00000000..05e53b16
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/.travis.yml
@@ -0,0 +1,14 @@
+language: go
+go:
+ - 1.9.x
+ - 1.10.x
+ - tip
+install:
+ - make dependency
+script:
+ - make test
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
+matrix:
+ allow_failures:
+ - go: tip
diff --git a/src/dma/vendor/github.com/labstack/echo/Gopkg.lock b/src/dma/vendor/github.com/labstack/echo/Gopkg.lock
new file mode 100644
index 00000000..f3c3b8d2
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/Gopkg.lock
@@ -0,0 +1,75 @@
+# 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
new file mode 100644
index 00000000..61de60cb
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/Gopkg.toml
@@ -0,0 +1,42 @@
+
+# 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/LICENSE b/src/dma/vendor/github.com/labstack/echo/LICENSE
new file mode 100644
index 00000000..b5b006b4
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 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
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/src/dma/vendor/github.com/labstack/echo/Makefile b/src/dma/vendor/github.com/labstack/echo/Makefile
new file mode 100644
index 00000000..494667d8
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/Makefile
@@ -0,0 +1,17 @@
+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
new file mode 100644
index 00000000..0f609df4
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/README.md
@@ -0,0 +1,99 @@
+<a href="https://echo.labstack.com"><img height="80" src="https://cdn.labstack.com/images/echo-logo.svg"></a>
+
+[![Sourcegraph](https://sourcegraph.com/github.com/labstack/echo/-/badge.svg?style=flat-square)](https://sourcegraph.com/github.com/labstack/echo?badge)
+[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/echo)
+[![Go Report Card](https://goreportcard.com/badge/github.com/labstack/echo?style=flat-square)](https://goreportcard.com/report/github.com/labstack/echo)
+[![Build Status](http://img.shields.io/travis/labstack/echo.svg?style=flat-square)](https://travis-ci.org/labstack/echo)
+[![Codecov](https://img.shields.io/codecov/c/github/labstack/echo.svg?style=flat-square)](https://codecov.io/gh/labstack/echo)
+[![Join the chat at https://gitter.im/labstack/echo](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg?style=flat-square)](https://gitter.im/labstack/echo)
+[![Forum](https://img.shields.io/badge/community-forum-00afd1.svg?style=flat-square)](https://forum.labstack.com)
+[![Twitter](https://img.shields.io/badge/twitter-@labstack-55acee.svg?style=flat-square)](https://twitter.com/labstack)
+[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)
+
+## Feature Overview
+
+- Optimized HTTP router which smartly prioritize routes
+- Build robust and scalable RESTful APIs
+- Group APIs
+- Extensible middleware framework
+- Define middleware at root, group or route level
+- Data binding for JSON, XML and form payload
+- Handy functions to send variety of HTTP responses
+- Centralized HTTP error handling
+- Template rendering with any template engine
+- Define your format for the logger
+- Highly customizable
+- Automatic TLS via Let’s Encrypt
+- HTTP/2 support
+
+## Benchmarks
+
+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">
+
+## [Guide](https://echo.labstack.com/guide)
+
+### Example
+
+```go
+package main
+
+import (
+ "net/http"
+
+ "github.com/labstack/echo"
+ "github.com/labstack/echo/middleware"
+)
+
+func main() {
+ // Echo instance
+ e := echo.New()
+
+ // Middleware
+ e.Use(middleware.Logger())
+ e.Use(middleware.Recover())
+
+ // Routes
+ e.GET("/", hello)
+
+ // Start server
+ e.Logger.Fatal(e.Start(":1323"))
+}
+
+// Handler
+func hello(c echo.Context) error {
+ return c.String(http.StatusOK, "Hello, World!")
+}
+```
+
+## Help
+
+- [Forum](https://forum.labstack.com)
+- [Chat](https://gitter.im/labstack/echo)
+
+## Contribute
+
+**Use issues for everything**
+
+- For a small change, just send a PR.
+- For bigger changes open an issue for discussion before sending a PR.
+- PR should have:
+ - Test case
+ - Documentation
+ - Example (If it makes sense)
+- You can also contribute by:
+ - Reporting issues
+ - Suggesting new features or enhancements
+ - Improve/fix documentation
+
+## Credits
+- [Vishal Rana](https://github.com/vishr) - Author
+- [Nitin Rana](https://github.com/nr17) - Consultant
+- [Contributors](https://github.com/labstack/echo/graphs/contributors)
+
+## License
+
+[MIT](https://github.com/labstack/echo/blob/master/LICENSE)
diff --git a/src/dma/vendor/github.com/labstack/echo/bind.go b/src/dma/vendor/github.com/labstack/echo/bind.go
new file mode 100644
index 00000000..38e07150
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/bind.go
@@ -0,0 +1,261 @@
+package echo
+
+import (
+ "encoding/json"
+ "encoding/xml"
+ "errors"
+ "fmt"
+ "net/http"
+ "reflect"
+ "strconv"
+ "strings"
+)
+
+type (
+ // Binder is the interface that wraps the Bind method.
+ Binder interface {
+ Bind(i interface{}, c Context) error
+ }
+
+ // DefaultBinder is the default implementation of the Binder interface.
+ DefaultBinder struct{}
+
+ // BindUnmarshaler is the interface used to wrap the UnmarshalParam method.
+ BindUnmarshaler interface {
+ // UnmarshalParam decodes and assigns a value from an form or query param.
+ UnmarshalParam(param string) error
+ }
+)
+
+// Bind implements the `Binder#Bind` function.
+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 err = b.bindData(i, c.QueryParams(), "query"); err != nil {
+ return NewHTTPError(http.StatusBadRequest, err.Error())
+ }
+ return
+ }
+ return NewHTTPError(http.StatusBadRequest, "Request body can't be empty")
+ }
+ ctype := req.Header.Get(HeaderContentType)
+ switch {
+ 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))
+ } else if se, ok := err.(*json.SyntaxError); ok {
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", se.Offset, se.Error()))
+ } else {
+ 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()))
+ } else if se, ok := err.(*xml.SyntaxError); ok {
+ return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: line=%v, error=%v", se.Line, se.Error()))
+ } else {
+ 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())
+ }
+ if err = b.bindData(i, params, "form"); err != nil {
+ return NewHTTPError(http.StatusBadRequest, err.Error())
+ }
+ default:
+ return ErrUnsupportedMediaType
+ }
+ return
+}
+
+func (b *DefaultBinder) bindData(ptr interface{}, data map[string][]string, tag string) error {
+ typ := reflect.TypeOf(ptr).Elem()
+ val := reflect.ValueOf(ptr).Elem()
+
+ if typ.Kind() != reflect.Struct {
+ return errors.New("binding element must be a struct")
+ }
+
+ for i := 0; i < typ.NumField(); i++ {
+ typeField := typ.Field(i)
+ structField := val.Field(i)
+ if !structField.CanSet() {
+ continue
+ }
+ structFieldKind := structField.Kind()
+ inputFieldName := typeField.Tag.Get(tag)
+
+ if inputFieldName == "" {
+ 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 {
+ return err
+ }
+ continue
+ }
+ }
+ inputValue, exists := data[inputFieldName]
+ if !exists {
+ continue
+ }
+
+ // Call this first, in case we're dealing with an alias to an array type
+ if ok, err := unmarshalField(typeField.Type.Kind(), inputValue[0], structField); ok {
+ if err != nil {
+ return err
+ }
+ continue
+ }
+
+ numElems := len(inputValue)
+ if structFieldKind == reflect.Slice && numElems > 0 {
+ sliceOf := structField.Type().Elem().Kind()
+ slice := reflect.MakeSlice(structField.Type(), numElems, numElems)
+ for j := 0; j < numElems; j++ {
+ if err := setWithProperType(sliceOf, inputValue[j], slice.Index(j)); err != nil {
+ return err
+ }
+ }
+ val.Field(i).Set(slice)
+ } else {
+ if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+func setWithProperType(valueKind reflect.Kind, val string, structField reflect.Value) error {
+ // But also call it here, in case we're dealing with an array of BindUnmarshalers
+ if ok, err := unmarshalField(valueKind, val, structField); ok {
+ return err
+ }
+
+ switch valueKind {
+ case reflect.Ptr:
+ return setWithProperType(structField.Elem().Kind(), val, structField.Elem())
+ case reflect.Int:
+ return setIntField(val, 0, structField)
+ case reflect.Int8:
+ return setIntField(val, 8, structField)
+ case reflect.Int16:
+ return setIntField(val, 16, structField)
+ case reflect.Int32:
+ return setIntField(val, 32, structField)
+ case reflect.Int64:
+ return setIntField(val, 64, structField)
+ case reflect.Uint:
+ return setUintField(val, 0, structField)
+ case reflect.Uint8:
+ return setUintField(val, 8, structField)
+ case reflect.Uint16:
+ return setUintField(val, 16, structField)
+ case reflect.Uint32:
+ return setUintField(val, 32, structField)
+ case reflect.Uint64:
+ return setUintField(val, 64, structField)
+ case reflect.Bool:
+ return setBoolField(val, structField)
+ case reflect.Float32:
+ return setFloatField(val, 32, structField)
+ case reflect.Float64:
+ return setFloatField(val, 64, structField)
+ case reflect.String:
+ structField.SetString(val)
+ default:
+ return errors.New("unknown type")
+ }
+ return nil
+}
+
+func unmarshalField(valueKind reflect.Kind, val string, field reflect.Value) (bool, error) {
+ switch valueKind {
+ case reflect.Ptr:
+ return unmarshalFieldPtr(val, field)
+ default:
+ return unmarshalFieldNonPtr(val, field)
+ }
+}
+
+// bindUnmarshaler attempts to unmarshal a reflect.Value into a BindUnmarshaler
+func bindUnmarshaler(field reflect.Value) (BindUnmarshaler, bool) {
+ ptr := reflect.New(field.Type())
+ if ptr.CanInterface() {
+ iface := ptr.Interface()
+ if unmarshaler, ok := iface.(BindUnmarshaler); ok {
+ return unmarshaler, ok
+ }
+ }
+ return nil, false
+}
+
+func unmarshalFieldNonPtr(value string, field reflect.Value) (bool, error) {
+ if unmarshaler, ok := bindUnmarshaler(field); ok {
+ err := unmarshaler.UnmarshalParam(value)
+ field.Set(reflect.ValueOf(unmarshaler).Elem())
+ return true, err
+ }
+ return false, nil
+}
+
+func unmarshalFieldPtr(value string, field reflect.Value) (bool, error) {
+ if field.IsNil() {
+ // Initialize the pointer to a nil value
+ field.Set(reflect.New(field.Type().Elem()))
+ }
+ return unmarshalFieldNonPtr(value, field.Elem())
+}
+
+func setIntField(value string, bitSize int, field reflect.Value) error {
+ if value == "" {
+ value = "0"
+ }
+ intVal, err := strconv.ParseInt(value, 10, bitSize)
+ if err == nil {
+ field.SetInt(intVal)
+ }
+ return err
+}
+
+func setUintField(value string, bitSize int, field reflect.Value) error {
+ if value == "" {
+ value = "0"
+ }
+ uintVal, err := strconv.ParseUint(value, 10, bitSize)
+ if err == nil {
+ field.SetUint(uintVal)
+ }
+ return err
+}
+
+func setBoolField(value string, field reflect.Value) error {
+ if value == "" {
+ value = "false"
+ }
+ boolVal, err := strconv.ParseBool(value)
+ if err == nil {
+ field.SetBool(boolVal)
+ }
+ return err
+}
+
+func setFloatField(value string, bitSize int, field reflect.Value) error {
+ if value == "" {
+ value = "0.0"
+ }
+ floatVal, err := strconv.ParseFloat(value, bitSize)
+ if err == nil {
+ field.SetFloat(floatVal)
+ }
+ return err
+}
diff --git a/src/dma/vendor/github.com/labstack/echo/context.go b/src/dma/vendor/github.com/labstack/echo/context.go
new file mode 100644
index 00000000..cf780c51
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/context.go
@@ -0,0 +1,576 @@
+package echo
+
+import (
+ "bytes"
+ "encoding/json"
+ "encoding/xml"
+ "fmt"
+ "io"
+ "mime/multipart"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+type (
+ // Context represents the context of the current HTTP request. It holds request and
+ // response objects, path, path parameters, data and registered handler.
+ Context interface {
+ // Request returns `*http.Request`.
+ Request() *http.Request
+
+ // SetRequest sets `*http.Request`.
+ SetRequest(r *http.Request)
+
+ // Response returns `*Response`.
+ Response() *Response
+
+ // IsTLS returns true if HTTP connection is TLS otherwise false.
+ IsTLS() bool
+
+ // IsWebSocket returns true if HTTP connection is WebSocket otherwise false.
+ IsWebSocket() bool
+
+ // Scheme returns the HTTP protocol scheme, `http` or `https`.
+ Scheme() string
+
+ // RealIP returns the client's network address based on `X-Forwarded-For`
+ // or `X-Real-IP` request header.
+ RealIP() string
+
+ // Path returns the registered path for the handler.
+ Path() string
+
+ // SetPath sets the registered path for the handler.
+ SetPath(p string)
+
+ // Param returns path parameter by name.
+ Param(name string) string
+
+ // ParamNames returns path parameter names.
+ ParamNames() []string
+
+ // SetParamNames sets path parameter names.
+ SetParamNames(names ...string)
+
+ // ParamValues returns path parameter values.
+ ParamValues() []string
+
+ // SetParamValues sets path parameter values.
+ SetParamValues(values ...string)
+
+ // QueryParam returns the query param for the provided name.
+ QueryParam(name string) string
+
+ // QueryParams returns the query parameters as `url.Values`.
+ QueryParams() url.Values
+
+ // QueryString returns the URL query string.
+ QueryString() string
+
+ // FormValue returns the form field value for the provided name.
+ FormValue(name string) string
+
+ // FormParams returns the form parameters as `url.Values`.
+ FormParams() (url.Values, error)
+
+ // FormFile returns the multipart form file for the provided name.
+ FormFile(name string) (*multipart.FileHeader, error)
+
+ // MultipartForm returns the multipart form.
+ MultipartForm() (*multipart.Form, error)
+
+ // Cookie returns the named cookie provided in the request.
+ Cookie(name string) (*http.Cookie, error)
+
+ // SetCookie adds a `Set-Cookie` header in HTTP response.
+ SetCookie(cookie *http.Cookie)
+
+ // Cookies returns the HTTP cookies sent with the request.
+ Cookies() []*http.Cookie
+
+ // Get retrieves data from the context.
+ Get(key string) interface{}
+
+ // Set saves data in the context.
+ Set(key string, val interface{})
+
+ // Bind binds the request body into provided type `i`. The default binder
+ // does it based on Content-Type header.
+ Bind(i interface{}) error
+
+ // Validate validates provided `i`. It is usually called after `Context#Bind()`.
+ // Validator must be registered using `Echo#Validator`.
+ Validate(i interface{}) error
+
+ // Render renders a template with data and sends a text/html response with status
+ // code. Renderer must be registered using `Echo.Renderer`.
+ Render(code int, name string, data interface{}) error
+
+ // HTML sends an HTTP response with status code.
+ HTML(code int, html string) error
+
+ // HTMLBlob sends an HTTP blob response with status code.
+ HTMLBlob(code int, b []byte) error
+
+ // String sends a string response with status code.
+ String(code int, s string) error
+
+ // JSON sends a JSON response with status code.
+ JSON(code int, i interface{}) error
+
+ // JSONPretty sends a pretty-print JSON with status code.
+ JSONPretty(code int, i interface{}, indent string) error
+
+ // JSONBlob sends a JSON blob response with status code.
+ JSONBlob(code int, b []byte) error
+
+ // JSONP sends a JSONP response with status code. It uses `callback` to construct
+ // the JSONP payload.
+ JSONP(code int, callback string, i interface{}) error
+
+ // JSONPBlob sends a JSONP blob response with status code. It uses `callback`
+ // to construct the JSONP payload.
+ JSONPBlob(code int, callback string, b []byte) error
+
+ // XML sends an XML response with status code.
+ XML(code int, i interface{}) error
+
+ // XMLPretty sends a pretty-print XML with status code.
+ XMLPretty(code int, i interface{}, indent string) error
+
+ // XMLBlob sends an XML blob response with status code.
+ XMLBlob(code int, b []byte) error
+
+ // Blob sends a blob response with status code and content type.
+ Blob(code int, contentType string, b []byte) error
+
+ // Stream sends a streaming response with status code and content type.
+ Stream(code int, contentType string, r io.Reader) error
+
+ // File sends a response with the content of the file.
+ File(file string) error
+
+ // Attachment sends a response as attachment, prompting client to save the
+ // file.
+ Attachment(file string, name string) error
+
+ // Inline sends a response as inline, opening the file in the browser.
+ Inline(file string, name string) error
+
+ // NoContent sends a response with no body and a status code.
+ NoContent(code int) error
+
+ // Redirect redirects the request to a provided URL with status code.
+ Redirect(code int, url string) error
+
+ // Error invokes the registered HTTP error handler. Generally used by middleware.
+ Error(err error)
+
+ // Handler returns the matched handler by router.
+ Handler() HandlerFunc
+
+ // SetHandler sets the matched handler by router.
+ SetHandler(h HandlerFunc)
+
+ // Logger returns the `Logger` instance.
+ Logger() Logger
+
+ // Echo returns the `Echo` instance.
+ Echo() *Echo
+
+ // Reset resets the context after request completes. It must be called along
+ // with `Echo#AcquireContext()` and `Echo#ReleaseContext()`.
+ // See `Echo#ServeHTTP()`
+ Reset(r *http.Request, w http.ResponseWriter)
+ }
+
+ context struct {
+ request *http.Request
+ response *Response
+ path string
+ pnames []string
+ pvalues []string
+ query url.Values
+ handler HandlerFunc
+ store Map
+ echo *Echo
+ }
+)
+
+const (
+ defaultMemory = 32 << 20 // 32 MB
+ indexPage = "index.html"
+)
+
+func (c *context) writeContentType(value string) {
+ header := c.Response().Header()
+ if header.Get(HeaderContentType) == "" {
+ header.Set(HeaderContentType, value)
+ }
+}
+
+func (c *context) Request() *http.Request {
+ return c.request
+}
+
+func (c *context) SetRequest(r *http.Request) {
+ c.request = r
+}
+
+func (c *context) Response() *Response {
+ return c.response
+}
+
+func (c *context) IsTLS() bool {
+ return c.request.TLS != nil
+}
+
+func (c *context) IsWebSocket() bool {
+ upgrade := c.request.Header.Get(HeaderUpgrade)
+ return upgrade == "websocket" || upgrade == "Websocket"
+}
+
+func (c *context) Scheme() string {
+ // Can't use `r.Request.URL.Scheme`
+ // See: https://groups.google.com/forum/#!topic/golang-nuts/pMUkBlQBDF0
+ if c.IsTLS() {
+ return "https"
+ }
+ if scheme := c.request.Header.Get(HeaderXForwardedProto); scheme != "" {
+ return scheme
+ }
+ if scheme := c.request.Header.Get(HeaderXForwardedProtocol); scheme != "" {
+ return scheme
+ }
+ if ssl := c.request.Header.Get(HeaderXForwardedSsl); ssl == "on" {
+ return "https"
+ }
+ if scheme := c.request.Header.Get(HeaderXUrlScheme); scheme != "" {
+ return scheme
+ }
+ return "http"
+}
+
+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 ra
+}
+
+func (c *context) Path() string {
+ return c.path
+}
+
+func (c *context) SetPath(p string) {
+ c.path = p
+}
+
+func (c *context) Param(name string) string {
+ for i, n := range c.pnames {
+ if i < len(c.pvalues) {
+ if n == name {
+ return c.pvalues[i]
+ }
+ }
+ }
+ return ""
+}
+
+func (c *context) ParamNames() []string {
+ return c.pnames
+}
+
+func (c *context) SetParamNames(names ...string) {
+ c.pnames = names
+}
+
+func (c *context) ParamValues() []string {
+ return c.pvalues[:len(c.pnames)]
+}
+
+func (c *context) SetParamValues(values ...string) {
+ c.pvalues = values
+}
+
+func (c *context) QueryParam(name string) string {
+ if c.query == nil {
+ c.query = c.request.URL.Query()
+ }
+ return c.query.Get(name)
+}
+
+func (c *context) QueryParams() url.Values {
+ if c.query == nil {
+ c.query = c.request.URL.Query()
+ }
+ return c.query
+}
+
+func (c *context) QueryString() string {
+ return c.request.URL.RawQuery
+}
+
+func (c *context) FormValue(name string) string {
+ return c.request.FormValue(name)
+}
+
+func (c *context) FormParams() (url.Values, error) {
+ if strings.HasPrefix(c.request.Header.Get(HeaderContentType), MIMEMultipartForm) {
+ if err := c.request.ParseMultipartForm(defaultMemory); err != nil {
+ return nil, err
+ }
+ } else {
+ if err := c.request.ParseForm(); err != nil {
+ return nil, err
+ }
+ }
+ return c.request.Form, nil
+}
+
+func (c *context) FormFile(name string) (*multipart.FileHeader, error) {
+ _, fh, err := c.request.FormFile(name)
+ return fh, err
+}
+
+func (c *context) MultipartForm() (*multipart.Form, error) {
+ err := c.request.ParseMultipartForm(defaultMemory)
+ return c.request.MultipartForm, err
+}
+
+func (c *context) Cookie(name string) (*http.Cookie, error) {
+ return c.request.Cookie(name)
+}
+
+func (c *context) SetCookie(cookie *http.Cookie) {
+ http.SetCookie(c.Response(), cookie)
+}
+
+func (c *context) Cookies() []*http.Cookie {
+ return c.request.Cookies()
+}
+
+func (c *context) Get(key string) interface{} {
+ return c.store[key]
+}
+
+func (c *context) Set(key string, val interface{}) {
+ if c.store == nil {
+ c.store = make(Map)
+ }
+ c.store[key] = val
+}
+
+func (c *context) Bind(i interface{}) error {
+ return c.echo.Binder.Bind(i, c)
+}
+
+func (c *context) Validate(i interface{}) error {
+ if c.echo.Validator == nil {
+ return ErrValidatorNotRegistered
+ }
+ return c.echo.Validator.Validate(i)
+}
+
+func (c *context) Render(code int, name string, data interface{}) (err error) {
+ if c.echo.Renderer == nil {
+ return ErrRendererNotRegistered
+ }
+ buf := new(bytes.Buffer)
+ if err = c.echo.Renderer.Render(buf, name, data, c); err != nil {
+ return
+ }
+ return c.HTMLBlob(code, buf.Bytes())
+}
+
+func (c *context) HTML(code int, html string) (err error) {
+ return c.HTMLBlob(code, []byte(html))
+}
+
+func (c *context) HTMLBlob(code int, b []byte) (err error) {
+ return c.Blob(code, MIMETextHTMLCharsetUTF8, b)
+}
+
+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) {
+ _, pretty := c.QueryParams()["pretty"]
+ if c.echo.Debug || pretty {
+ return c.JSONPretty(code, i, " ")
+ }
+ b, err := json.Marshal(i)
+ if err != nil {
+ return
+ }
+ return c.JSONBlob(code, b)
+}
+
+func (c *context) JSONPretty(code int, i interface{}, indent string) (err error) {
+ b, err := json.MarshalIndent(i, "", indent)
+ if err != nil {
+ return
+ }
+ return c.JSONBlob(code, b)
+}
+
+func (c *context) JSONBlob(code int, b []byte) (err error) {
+ return c.Blob(code, MIMEApplicationJSONCharsetUTF8, b)
+}
+
+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)
+}
+
+func (c *context) JSONPBlob(code int, callback string, b []byte) (err error) {
+ c.writeContentType(MIMEApplicationJavaScriptCharsetUTF8)
+ c.response.WriteHeader(code)
+ if _, err = c.response.Write([]byte(callback + "(")); err != nil {
+ return
+ }
+ if _, err = c.response.Write(b); err != nil {
+ return
+ }
+ _, err = c.response.Write([]byte(");"))
+ 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, " ")
+ }
+ b, err := xml.Marshal(i)
+ if err != nil {
+ return
+ }
+ return c.XMLBlob(code, b)
+}
+
+func (c *context) XMLPretty(code int, i interface{}, indent string) (err error) {
+ b, err := xml.MarshalIndent(i, "", indent)
+ if err != nil {
+ return
+ }
+ return c.XMLBlob(code, b)
+}
+
+func (c *context) XMLBlob(code int, b []byte) (err error) {
+ c.writeContentType(MIMEApplicationXMLCharsetUTF8)
+ c.response.WriteHeader(code)
+ if _, err = c.response.Write([]byte(xml.Header)); err != nil {
+ return
+ }
+ _, err = c.response.Write(b)
+ return
+}
+
+func (c *context) Blob(code int, contentType string, b []byte) (err error) {
+ c.writeContentType(contentType)
+ c.response.WriteHeader(code)
+ _, err = c.response.Write(b)
+ return
+}
+
+func (c *context) Stream(code int, contentType string, r io.Reader) (err error) {
+ c.writeContentType(contentType)
+ c.response.WriteHeader(code)
+ _, err = io.Copy(c.response, r)
+ return
+}
+
+func (c *context) File(file string) (err error) {
+ f, err := os.Open(file)
+ if err != nil {
+ return NotFoundHandler(c)
+ }
+ defer f.Close()
+
+ fi, _ := f.Stat()
+ if fi.IsDir() {
+ file = filepath.Join(file, indexPage)
+ f, err = os.Open(file)
+ if err != nil {
+ return NotFoundHandler(c)
+ }
+ defer f.Close()
+ if fi, err = f.Stat(); err != nil {
+ return
+ }
+ }
+ http.ServeContent(c.Response(), c.Request(), fi.Name(), fi.ModTime(), f)
+ return
+}
+
+func (c *context) Attachment(file, name string) error {
+ return c.contentDisposition(file, name, "attachment")
+}
+
+func (c *context) Inline(file, name string) error {
+ return c.contentDisposition(file, name, "inline")
+}
+
+func (c *context) contentDisposition(file, name, dispositionType string) error {
+ c.response.Header().Set(HeaderContentDisposition, fmt.Sprintf("%s; filename=%q", dispositionType, name))
+ return c.File(file)
+}
+
+func (c *context) NoContent(code int) error {
+ c.response.WriteHeader(code)
+ return nil
+}
+
+func (c *context) Redirect(code int, url string) error {
+ if code < 300 || code > 308 {
+ return ErrInvalidRedirectCode
+ }
+ c.response.Header().Set(HeaderLocation, url)
+ c.response.WriteHeader(code)
+ return nil
+}
+
+func (c *context) Error(err error) {
+ c.echo.HTTPErrorHandler(err, c)
+}
+
+func (c *context) Echo() *Echo {
+ return c.echo
+}
+
+func (c *context) Handler() HandlerFunc {
+ return c.handler
+}
+
+func (c *context) SetHandler(h HandlerFunc) {
+ c.handler = h
+}
+
+func (c *context) Logger() Logger {
+ return c.echo.Logger
+}
+
+func (c *context) Reset(r *http.Request, w http.ResponseWriter) {
+ c.request = r
+ c.response.reset(w)
+ c.query = nil
+ c.handler = NotFoundHandler
+ c.store = nil
+ c.path = ""
+ c.pnames = nil
+ // 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
new file mode 100644
index 00000000..41ac6b5e
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/echo.go
@@ -0,0 +1,781 @@
+/*
+Package echo implements high performance, minimalist Go web framework.
+
+Example:
+
+ package main
+
+ import (
+ "net/http"
+
+ "github.com/labstack/echo"
+ "github.com/labstack/echo/middleware"
+ )
+
+ // Handler
+ func hello(c echo.Context) error {
+ return c.String(http.StatusOK, "Hello, World!")
+ }
+
+ func main() {
+ // Echo instance
+ e := echo.New()
+
+ // Middleware
+ e.Use(middleware.Logger())
+ e.Use(middleware.Recover())
+
+ // Routes
+ e.GET("/", hello)
+
+ // Start server
+ e.Logger.Fatal(e.Start(":1323"))
+ }
+
+Learn more at https://echo.labstack.com
+*/
+package echo
+
+import (
+ "bytes"
+ stdContext "context"
+ "crypto/tls"
+ "errors"
+ "fmt"
+ "io"
+ stdLog "log"
+ "net"
+ "net/http"
+ "net/url"
+ "path"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "sync"
+ "time"
+
+ "github.com/labstack/gommon/color"
+ "github.com/labstack/gommon/log"
+ "golang.org/x/crypto/acme/autocert"
+)
+
+type (
+ // Echo is the top-level framework instance.
+ Echo struct {
+ stdLogger *stdLog.Logger
+ colorer *color.Color
+ premiddleware []MiddlewareFunc
+ middleware []MiddlewareFunc
+ maxParam *int
+ router *Router
+ notFoundHandler HandlerFunc
+ pool sync.Pool
+ Server *http.Server
+ TLSServer *http.Server
+ Listener net.Listener
+ TLSListener net.Listener
+ AutoTLSManager autocert.Manager
+ DisableHTTP2 bool
+ Debug bool
+ HideBanner bool
+ HidePort bool
+ HTTPErrorHandler HTTPErrorHandler
+ Binder Binder
+ Validator Validator
+ Renderer Renderer
+ Logger Logger
+ }
+
+ // Route contains a handler and information for matching against requests.
+ Route struct {
+ Method string `json:"method"`
+ Path string `json:"path"`
+ Name string `json:"name"`
+ }
+
+ // HTTPError represents an error that occurred while handling a request.
+ HTTPError struct {
+ Code int
+ Message interface{}
+ Internal error // Stores the error returned by an external dependency
+ }
+
+ // MiddlewareFunc defines a function to process middleware.
+ MiddlewareFunc func(HandlerFunc) HandlerFunc
+
+ // HandlerFunc defines a function to server HTTP requests.
+ HandlerFunc func(Context) error
+
+ // HTTPErrorHandler is a centralized HTTP error handler.
+ HTTPErrorHandler func(error, Context)
+
+ // Validator is the interface that wraps the Validate function.
+ Validator interface {
+ Validate(i interface{}) error
+ }
+
+ // Renderer is the interface that wraps the Render function.
+ Renderer interface {
+ Render(io.Writer, string, interface{}, Context) error
+ }
+
+ // Map defines a generic map of type `map[string]interface{}`.
+ Map map[string]interface{}
+
+ // i is the interface for Echo and Group.
+ i interface {
+ GET(string, HandlerFunc, ...MiddlewareFunc) *Route
+ }
+)
+
+// HTTP methods
+const (
+ CONNECT = "CONNECT"
+ DELETE = "DELETE"
+ GET = "GET"
+ HEAD = "HEAD"
+ OPTIONS = "OPTIONS"
+ PATCH = "PATCH"
+ POST = "POST"
+ PROPFIND = "PROPFIND"
+ PUT = "PUT"
+ TRACE = "TRACE"
+)
+
+// MIME types
+const (
+ MIMEApplicationJSON = "application/json"
+ MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8
+ MIMEApplicationJavaScript = "application/javascript"
+ MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
+ MIMEApplicationXML = "application/xml"
+ MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8
+ MIMETextXML = "text/xml"
+ MIMETextXMLCharsetUTF8 = MIMETextXML + "; " + charsetUTF8
+ MIMEApplicationForm = "application/x-www-form-urlencoded"
+ MIMEApplicationProtobuf = "application/protobuf"
+ MIMEApplicationMsgpack = "application/msgpack"
+ MIMETextHTML = "text/html"
+ MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8
+ MIMETextPlain = "text/plain"
+ MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8
+ MIMEMultipartForm = "multipart/form-data"
+ MIMEOctetStream = "application/octet-stream"
+)
+
+const (
+ charsetUTF8 = "charset=UTF-8"
+)
+
+// Headers
+const (
+ HeaderAccept = "Accept"
+ HeaderAcceptEncoding = "Accept-Encoding"
+ HeaderAllow = "Allow"
+ HeaderAuthorization = "Authorization"
+ HeaderContentDisposition = "Content-Disposition"
+ HeaderContentEncoding = "Content-Encoding"
+ HeaderContentLength = "Content-Length"
+ HeaderContentType = "Content-Type"
+ HeaderCookie = "Cookie"
+ HeaderSetCookie = "Set-Cookie"
+ HeaderIfModifiedSince = "If-Modified-Since"
+ HeaderLastModified = "Last-Modified"
+ HeaderLocation = "Location"
+ HeaderUpgrade = "Upgrade"
+ HeaderVary = "Vary"
+ HeaderWWWAuthenticate = "WWW-Authenticate"
+ HeaderXForwardedFor = "X-Forwarded-For"
+ HeaderXForwardedProto = "X-Forwarded-Proto"
+ HeaderXForwardedProtocol = "X-Forwarded-Protocol"
+ HeaderXForwardedSsl = "X-Forwarded-Ssl"
+ HeaderXUrlScheme = "X-Url-Scheme"
+ HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
+ HeaderXRealIP = "X-Real-IP"
+ HeaderXRequestID = "X-Request-ID"
+ HeaderXRequestedWith = "X-Requested-With"
+ HeaderServer = "Server"
+ HeaderOrigin = "Origin"
+
+ // Access control
+ HeaderAccessControlRequestMethod = "Access-Control-Request-Method"
+ HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers"
+ HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin"
+ HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods"
+ HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers"
+ HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
+ HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers"
+ HeaderAccessControlMaxAge = "Access-Control-Max-Age"
+
+ // Security
+ HeaderStrictTransportSecurity = "Strict-Transport-Security"
+ HeaderXContentTypeOptions = "X-Content-Type-Options"
+ HeaderXXSSProtection = "X-XSS-Protection"
+ HeaderXFrameOptions = "X-Frame-Options"
+ HeaderContentSecurityPolicy = "Content-Security-Policy"
+ HeaderXCSRFToken = "X-CSRF-Token"
+)
+
+const (
+ Version = "3.3.5"
+ website = "https://echo.labstack.com"
+ // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
+ banner = `
+ ____ __
+ / __/___/ / ___
+ / _// __/ _ \/ _ \
+/___/\__/_//_/\___/ %s
+High performance, minimalist Go web framework
+%s
+____________________________________O/_______
+ O\
+`
+)
+
+var (
+ methods = [...]string{
+ CONNECT,
+ DELETE,
+ GET,
+ HEAD,
+ OPTIONS,
+ PATCH,
+ POST,
+ PROPFIND,
+ PUT,
+ TRACE,
+ }
+)
+
+// Errors
+var (
+ ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType)
+ ErrNotFound = NewHTTPError(http.StatusNotFound)
+ ErrUnauthorized = NewHTTPError(http.StatusUnauthorized)
+ ErrForbidden = NewHTTPError(http.StatusForbidden)
+ ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed)
+ ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge)
+ ErrValidatorNotRegistered = errors.New("validator not registered")
+ ErrRendererNotRegistered = errors.New("renderer not registered")
+ ErrInvalidRedirectCode = errors.New("invalid redirect status code")
+ ErrCookieNotFound = errors.New("cookie not found")
+)
+
+// Error handlers
+var (
+ NotFoundHandler = func(c Context) error {
+ return ErrNotFound
+ }
+
+ MethodNotAllowedHandler = func(c Context) error {
+ return ErrMethodNotAllowed
+ }
+)
+
+// New creates an instance of Echo.
+func New() (e *Echo) {
+ e = &Echo{
+ Server: new(http.Server),
+ TLSServer: new(http.Server),
+ AutoTLSManager: autocert.Manager{
+ Prompt: autocert.AcceptTOS,
+ },
+ Logger: log.New("echo"),
+ colorer: color.New(),
+ maxParam: new(int),
+ }
+ e.Server.Handler = e
+ e.TLSServer.Handler = e
+ e.HTTPErrorHandler = e.DefaultHTTPErrorHandler
+ e.Binder = &DefaultBinder{}
+ e.Logger.SetLevel(log.ERROR)
+ e.stdLogger = stdLog.New(e.Logger.Output(), e.Logger.Prefix()+": ", 0)
+ e.pool.New = func() interface{} {
+ return e.NewContext(nil, nil)
+ }
+ e.router = NewRouter(e)
+ return
+}
+
+// NewContext returns a Context instance.
+func (e *Echo) NewContext(r *http.Request, w http.ResponseWriter) Context {
+ return &context{
+ request: r,
+ response: NewResponse(w, e),
+ store: make(Map),
+ echo: e,
+ pvalues: make([]string, *e.maxParam),
+ handler: NotFoundHandler,
+ }
+}
+
+// Router returns router.
+func (e *Echo) Router() *Router {
+ return e.router
+}
+
+// DefaultHTTPErrorHandler is the default HTTP error handler. It sends a JSON response
+// with status code.
+func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
+ var (
+ code = http.StatusInternalServerError
+ msg interface{}
+ )
+
+ if he, ok := err.(*HTTPError); ok {
+ code = he.Code
+ msg = he.Message
+ if he.Internal != nil {
+ msg = fmt.Sprintf("%v, %v", err, he.Internal)
+ }
+ } else if e.Debug {
+ msg = err.Error()
+ } else {
+ msg = http.StatusText(code)
+ }
+ if _, ok := msg.(string); ok {
+ msg = Map{"message": msg}
+ }
+
+ e.Logger.Error(err)
+
+ // Send response
+ if !c.Response().Committed {
+ if c.Request().Method == HEAD { // Issue #608
+ err = c.NoContent(code)
+ } else {
+ err = c.JSON(code, msg)
+ }
+ if err != nil {
+ e.Logger.Error(err)
+ }
+ }
+}
+
+// Pre adds middleware to the chain which is run before router.
+func (e *Echo) Pre(middleware ...MiddlewareFunc) {
+ e.premiddleware = append(e.premiddleware, middleware...)
+}
+
+// Use adds middleware to the chain which is run after router.
+func (e *Echo) Use(middleware ...MiddlewareFunc) {
+ e.middleware = append(e.middleware, middleware...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// Any registers a new route for all HTTP methods and path with matching handler
+// in the router with optional route-level middleware.
+func (e *Echo) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = e.Add(m, path, handler, middleware...)
+ }
+ return routes
+}
+
+// Match registers a new route for multiple HTTP methods and path with matching
+// handler in the router with optional route-level middleware.
+func (e *Echo) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = e.Add(m, path, handler, middleware...)
+ }
+ return routes
+}
+
+// Static registers a new route with path prefix to serve static files from the
+// provided root directory.
+func (e *Echo) Static(prefix, root string) *Route {
+ if root == "" {
+ root = "." // For security we want to restrict to CWD.
+ }
+ return static(e, prefix, root)
+}
+
+func static(i i, prefix, root string) *Route {
+ h := func(c Context) error {
+ p, err := url.PathUnescape(c.Param("*"))
+ if err != nil {
+ return err
+ }
+ name := filepath.Join(root, path.Clean("/"+p)) // "/"+ for security
+ return c.File(name)
+ }
+ i.GET(prefix, h)
+ if prefix == "/" {
+ return i.GET(prefix+"*", h)
+ }
+
+ 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 {
+ return e.GET(path, func(c Context) error {
+ return c.File(file)
+ })
+}
+
+// Add registers a new route for an HTTP method and path with matching handler
+// in the router with optional route-level middleware.
+func (e *Echo) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
+ name := handlerName(handler)
+ e.router.Add(method, path, func(c Context) error {
+ h := handler
+ // Chain middleware
+ for i := len(middleware) - 1; i >= 0; i-- {
+ h = middleware[i](h)
+ }
+ return h(c)
+ })
+ r := &Route{
+ Method: method,
+ Path: path,
+ Name: name,
+ }
+ e.router.routes[method+path] = r
+ return r
+}
+
+// Group creates a new router group with prefix and optional group-level middleware.
+func (e *Echo) Group(prefix string, m ...MiddlewareFunc) (g *Group) {
+ g = &Group{prefix: prefix, echo: e}
+ g.Use(m...)
+ return
+}
+
+// URI generates a URI from handler.
+func (e *Echo) URI(handler HandlerFunc, params ...interface{}) string {
+ name := handlerName(handler)
+ return e.Reverse(name, params...)
+}
+
+// URL is an alias for `URI` function.
+func (e *Echo) URL(h HandlerFunc, params ...interface{}) string {
+ return e.URI(h, params...)
+}
+
+// Reverse generates an URL from route name and provided parameters.
+func (e *Echo) Reverse(name string, params ...interface{}) string {
+ uri := new(bytes.Buffer)
+ ln := len(params)
+ n := 0
+ for _, r := range e.router.routes {
+ if r.Name == name {
+ for i, l := 0, len(r.Path); i < l; i++ {
+ if r.Path[i] == ':' && n < ln {
+ for ; i < l && r.Path[i] != '/'; i++ {
+ }
+ uri.WriteString(fmt.Sprintf("%v", params[n]))
+ n++
+ }
+ if i < l {
+ uri.WriteByte(r.Path[i])
+ }
+ }
+ break
+ }
+ }
+ return uri.String()
+}
+
+// Routes returns the registered routes.
+func (e *Echo) Routes() []*Route {
+ routes := make([]*Route, 0, len(e.router.routes))
+ for _, v := range e.router.routes {
+ routes = append(routes, v)
+ }
+ return routes
+}
+
+// AcquireContext returns an empty `Context` instance from the pool.
+// You must return the context by calling `ReleaseContext()`.
+func (e *Echo) AcquireContext() Context {
+ return e.pool.Get().(Context)
+}
+
+// ReleaseContext returns the `Context` instance back to the pool.
+// You must call it after `AcquireContext()`.
+func (e *Echo) ReleaseContext(c Context) {
+ e.pool.Put(c)
+}
+
+// ServeHTTP implements `http.Handler` interface, which serves HTTP requests.
+func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ // Acquire context
+ 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)
+ 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)
+ h := c.Handler()
+ for i := len(e.middleware) - 1; i >= 0; i-- {
+ h = e.middleware[i](h)
+ }
+ return h(c)
+ }
+ for i := len(e.premiddleware) - 1; i >= 0; i-- {
+ h = e.premiddleware[i](h)
+ }
+ }
+
+ // Execute chain
+ if err := h(c); err != nil {
+ e.HTTPErrorHandler(err, c)
+ }
+
+ // Release context
+ e.pool.Put(c)
+}
+
+// Start starts an HTTP server.
+func (e *Echo) Start(address string) error {
+ e.Server.Addr = address
+ return e.StartServer(e.Server)
+}
+
+// StartTLS starts an HTTPS server.
+func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
+ if certFile == "" || keyFile == "" {
+ return errors.New("invalid tls configuration")
+ }
+ s := e.TLSServer
+ s.TLSConfig = new(tls.Config)
+ s.TLSConfig.Certificates = make([]tls.Certificate, 1)
+ s.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
+ if err != nil {
+ return
+ }
+ return e.startTLS(address)
+}
+
+// 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
+ return e.startTLS(address)
+}
+
+func (e *Echo) startTLS(address string) error {
+ s := e.TLSServer
+ s.Addr = address
+ if !e.DisableHTTP2 {
+ s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "h2")
+ }
+ return e.StartServer(e.TLSServer)
+}
+
+// StartServer starts a custom http server.
+func (e *Echo) StartServer(s *http.Server) (err error) {
+ // Setup
+ e.colorer.SetOutput(e.Logger.Output())
+ s.ErrorLog = e.stdLogger
+ s.Handler = e
+ if e.Debug {
+ e.Logger.SetLevel(log.DEBUG)
+ }
+
+ if !e.HideBanner {
+ e.colorer.Printf(banner, e.colorer.Red("v"+Version), e.colorer.Blue(website))
+ }
+
+ if s.TLSConfig == nil {
+ if e.Listener == nil {
+ e.Listener, err = newListener(s.Addr)
+ if err != nil {
+ return err
+ }
+ }
+ if !e.HidePort {
+ e.colorer.Printf("⇨ http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
+ }
+ return s.Serve(e.Listener)
+ }
+ if e.TLSListener == nil {
+ l, err := newListener(s.Addr)
+ if err != nil {
+ return err
+ }
+ e.TLSListener = tls.NewListener(l, s.TLSConfig)
+ }
+ if !e.HidePort {
+ e.colorer.Printf("⇨ https server started on %s\n", e.colorer.Green(e.TLSListener.Addr()))
+ }
+ return s.Serve(e.TLSListener)
+}
+
+// Close immediately stops the server.
+// It internally calls `http.Server#Close()`.
+func (e *Echo) Close() error {
+ if err := e.TLSServer.Close(); err != nil {
+ return err
+ }
+ return e.Server.Close()
+}
+
+// Shutdown stops server the gracefully.
+// It internally calls `http.Server#Shutdown()`.
+func (e *Echo) Shutdown(ctx stdContext.Context) error {
+ if err := e.TLSServer.Shutdown(ctx); err != nil {
+ return err
+ }
+ return e.Server.Shutdown(ctx)
+}
+
+// NewHTTPError creates a new HTTPError instance.
+func NewHTTPError(code int, message ...interface{}) *HTTPError {
+ he := &HTTPError{Code: code, Message: http.StatusText(code)}
+ if len(message) > 0 {
+ he.Message = message[0]
+ }
+ return he
+}
+
+// Error makes it compatible with `error` interface.
+func (he *HTTPError) Error() string {
+ return fmt.Sprintf("code=%d, message=%v", he.Code, he.Message)
+}
+
+// WrapHandler wraps `http.Handler` into `echo.HandlerFunc`.
+func WrapHandler(h http.Handler) HandlerFunc {
+ return func(c Context) error {
+ h.ServeHTTP(c.Response(), c.Request())
+ return nil
+ }
+}
+
+// WrapMiddleware wraps `func(http.Handler) http.Handler` into `echo.MiddlewareFunc`
+func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc {
+ return func(next HandlerFunc) HandlerFunc {
+ return func(c Context) (err error) {
+ m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ c.SetRequest(r)
+ err = next(c)
+ })).ServeHTTP(c.Response(), c.Request())
+ return
+ }
+ }
+}
+
+func getPath(r *http.Request) string {
+ path := r.URL.RawPath
+ if path == "" {
+ path = r.URL.Path
+ }
+ return path
+}
+
+func handlerName(h HandlerFunc) string {
+ t := reflect.ValueOf(h).Type()
+ if t.Kind() == reflect.Func {
+ return runtime.FuncForPC(reflect.ValueOf(h).Pointer()).Name()
+ }
+ return t.String()
+}
+
+// // PathUnescape is wraps `url.PathUnescape`
+// func PathUnescape(s string) (string, error) {
+// return url.PathUnescape(s)
+// }
+
+// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted
+// connections. It's used by ListenAndServe and ListenAndServeTLS so
+// dead TCP connections (e.g. closing laptop mid-download) eventually
+// go away.
+type tcpKeepAliveListener struct {
+ *net.TCPListener
+}
+
+func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
+ tc, err := ln.AcceptTCP()
+ if err != nil {
+ return
+ }
+ tc.SetKeepAlive(true)
+ tc.SetKeepAlivePeriod(3 * time.Minute)
+ return tc, nil
+}
+
+func newListener(address string) (*tcpKeepAliveListener, error) {
+ l, err := net.Listen("tcp", address)
+ if err != nil {
+ return nil, err
+ }
+ return &tcpKeepAliveListener{l.(*net.TCPListener)}, nil
+}
diff --git a/src/dma/vendor/github.com/labstack/echo/group.go b/src/dma/vendor/github.com/labstack/echo/group.go
new file mode 100644
index 00000000..5257e83c
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/group.go
@@ -0,0 +1,120 @@
+package echo
+
+import (
+ "path"
+)
+
+type (
+ // Group is a set of sub-routes for a specified route. It can be used for inner
+ // routes that share a common middleware or functionality that should be separate
+ // from the parent echo instance while still inheriting from it.
+ Group struct {
+ prefix string
+ middleware []MiddlewareFunc
+ echo *Echo
+ }
+)
+
+// Use implements `Echo#Use()` for sub-routes within the Group.
+func (g *Group) Use(middleware ...MiddlewareFunc) {
+ g.middleware = append(g.middleware, middleware...)
+ // Allow all requests to reach the group as they might get dropped if router
+ // doesn't find a match, making none of the group middleware process.
+ for _, p := range []string{"", "/*"} {
+ g.echo.Any(path.Clean(g.prefix+p), func(c Context) error {
+ return NotFoundHandler(c)
+ }, g.middleware...)
+ }
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// 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...)
+}
+
+// Any implements `Echo#Any()` for sub-routes within the Group.
+func (g *Group) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = g.Add(m, path, handler, middleware...)
+ }
+ return routes
+}
+
+// Match implements `Echo#Match()` for sub-routes within the Group.
+func (g *Group) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
+ routes := make([]*Route, len(methods))
+ for i, m := range methods {
+ routes[i] = g.Add(m, path, handler, middleware...)
+ }
+ return routes
+}
+
+// Group creates a new sub-group with prefix and optional sub-group-level middleware.
+func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) *Group {
+ m := make([]MiddlewareFunc, 0, len(g.middleware)+len(middleware))
+ m = append(m, g.middleware...)
+ m = append(m, middleware...)
+ return g.echo.Group(g.prefix+prefix, m...)
+}
+
+// Static implements `Echo#Static()` for sub-routes within the Group.
+func (g *Group) Static(prefix, root string) {
+ static(g, prefix, root)
+}
+
+// File implements `Echo#File()` for sub-routes within the Group.
+func (g *Group) File(path, file string) {
+ g.echo.File(g.prefix+path, file)
+}
+
+// Add implements `Echo#Add()` for sub-routes within the Group.
+func (g *Group) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
+ // Combine into a new slice to avoid accidentally passing the same slice for
+ // multiple routes, which would lead to later add() calls overwriting the
+ // middleware from earlier calls.
+ m := make([]MiddlewareFunc, 0, len(g.middleware)+len(middleware))
+ m = append(m, g.middleware...)
+ m = append(m, middleware...)
+ return g.echo.Add(method, g.prefix+path, handler, m...)
+}
diff --git a/src/dma/vendor/github.com/labstack/echo/log.go b/src/dma/vendor/github.com/labstack/echo/log.go
new file mode 100644
index 00000000..b194c39c
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/log.go
@@ -0,0 +1,40 @@
+package echo
+
+import (
+ "io"
+
+ "github.com/labstack/gommon/log"
+)
+
+type (
+ // Logger defines the logging interface.
+ Logger interface {
+ Output() io.Writer
+ SetOutput(w io.Writer)
+ Prefix() string
+ SetPrefix(p string)
+ Level() log.Lvl
+ SetLevel(v log.Lvl)
+ Print(i ...interface{})
+ Printf(format string, args ...interface{})
+ Printj(j log.JSON)
+ Debug(i ...interface{})
+ Debugf(format string, args ...interface{})
+ Debugj(j log.JSON)
+ Info(i ...interface{})
+ Infof(format string, args ...interface{})
+ Infoj(j log.JSON)
+ Warn(i ...interface{})
+ Warnf(format string, args ...interface{})
+ Warnj(j log.JSON)
+ Error(i ...interface{})
+ Errorf(format string, args ...interface{})
+ Errorj(j log.JSON)
+ Fatal(i ...interface{})
+ Fatalj(j log.JSON)
+ Fatalf(format string, args ...interface{})
+ Panic(i ...interface{})
+ Panicj(j log.JSON)
+ Panicf(format string, args ...interface{})
+ }
+)
diff --git a/src/dma/vendor/github.com/labstack/echo/response.go b/src/dma/vendor/github.com/labstack/echo/response.go
new file mode 100644
index 00000000..6244783b
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/response.go
@@ -0,0 +1,110 @@
+package echo
+
+import (
+ "bufio"
+ "net"
+ "net/http"
+)
+
+type (
+ // Response wraps an http.ResponseWriter and implements its interface to be used
+ // by an HTTP handler to construct an HTTP response.
+ // See: https://golang.org/pkg/net/http/#ResponseWriter
+ Response struct {
+ echo *Echo
+ beforeFuncs []func()
+ afterFuncs []func()
+ Writer http.ResponseWriter
+ Status int
+ Size int64
+ Committed bool
+ }
+)
+
+// NewResponse creates a new instance of Response.
+func NewResponse(w http.ResponseWriter, e *Echo) (r *Response) {
+ return &Response{Writer: w, echo: e}
+}
+
+// Header returns the header map for the writer that will be sent by
+// WriteHeader. Changing the header after a call to WriteHeader (or Write) has
+// no effect unless the modified headers were declared as trailers by setting
+// the "Trailer" header before the call to WriteHeader (see example)
+// To suppress implicit response headers, set their value to nil.
+// Example: https://golang.org/pkg/net/http/#example_ResponseWriter_trailers
+func (r *Response) Header() http.Header {
+ return r.Writer.Header()
+}
+
+// Before registers a function which is called just before the response is written.
+func (r *Response) Before(fn func()) {
+ r.beforeFuncs = append(r.beforeFuncs, fn)
+}
+
+// After registers a function which is called just after the response is written.
+// If the `Content-Length` is unknown, none of the after function is executed.
+func (r *Response) After(fn func()) {
+ r.afterFuncs = append(r.afterFuncs, fn)
+}
+
+// WriteHeader sends an HTTP response header with status code. If WriteHeader is
+// not called explicitly, the first call to Write will trigger an implicit
+// WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly
+// used to send error codes.
+func (r *Response) WriteHeader(code int) {
+ if r.Committed {
+ r.echo.Logger.Warn("response already committed")
+ return
+ }
+ for _, fn := range r.beforeFuncs {
+ fn()
+ }
+ r.Status = code
+ r.Writer.WriteHeader(code)
+ r.Committed = true
+}
+
+// Write writes the data to the connection as part of an HTTP reply.
+func (r *Response) Write(b []byte) (n int, err error) {
+ if !r.Committed {
+ r.WriteHeader(http.StatusOK)
+ }
+ n, err = r.Writer.Write(b)
+ r.Size += int64(n)
+ for _, fn := range r.afterFuncs {
+ fn()
+ }
+ return
+}
+
+// Flush implements the http.Flusher interface to allow an HTTP handler to flush
+// buffered data to the client.
+// See [http.Flusher](https://golang.org/pkg/net/http/#Flusher)
+func (r *Response) Flush() {
+ r.Writer.(http.Flusher).Flush()
+}
+
+// Hijack implements the http.Hijacker interface to allow an HTTP handler to
+// take over the connection.
+// See [http.Hijacker](https://golang.org/pkg/net/http/#Hijacker)
+func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
+ return r.Writer.(http.Hijacker).Hijack()
+}
+
+// CloseNotify implements the http.CloseNotifier interface to allow detecting
+// when the underlying connection has gone away.
+// This mechanism can be used to cancel long operations on the server if the
+// client has disconnected before the response is ready.
+// See [http.CloseNotifier](https://golang.org/pkg/net/http/#CloseNotifier)
+func (r *Response) CloseNotify() <-chan bool {
+ return r.Writer.(http.CloseNotifier).CloseNotify()
+}
+
+func (r *Response) reset(w http.ResponseWriter) {
+ r.beforeFuncs = nil
+ r.afterFuncs = nil
+ r.Writer = w
+ r.Size = 0
+ r.Status = http.StatusOK
+ r.Committed = false
+}
diff --git a/src/dma/vendor/github.com/labstack/echo/router.go b/src/dma/vendor/github.com/labstack/echo/router.go
new file mode 100644
index 00000000..ff53da87
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/echo/router.go
@@ -0,0 +1,434 @@
+package echo
+
+type (
+ // Router is the registry of all registered routes for an `Echo` instance for
+ // request matching and URL path parameter parsing.
+ Router struct {
+ tree *node
+ routes map[string]*Route
+ echo *Echo
+ }
+ node struct {
+ kind kind
+ label byte
+ prefix string
+ parent *node
+ children children
+ ppath string
+ pnames []string
+ methodHandler *methodHandler
+ }
+ kind uint8
+ children []*node
+ methodHandler struct {
+ connect HandlerFunc
+ delete HandlerFunc
+ get HandlerFunc
+ head HandlerFunc
+ options HandlerFunc
+ patch HandlerFunc
+ post HandlerFunc
+ propfind HandlerFunc
+ put HandlerFunc
+ trace HandlerFunc
+ }
+)
+
+const (
+ skind kind = iota
+ pkind
+ akind
+)
+
+// NewRouter returns a new Router instance.
+func NewRouter(e *Echo) *Router {
+ return &Router{
+ tree: &node{
+ methodHandler: new(methodHandler),
+ },
+ routes: map[string]*Route{},
+ echo: e,
+ }
+}
+
+// Add registers a new route for method and path with matching handler.
+func (r *Router) Add(method, path string, h HandlerFunc) {
+ // Validate path
+ if path == "" {
+ panic("echo: path cannot be empty")
+ }
+ if path[0] != '/' {
+ path = "/" + path
+ }
+ pnames := []string{} // Param names
+ ppath := path // Pristine path
+
+ for i, l := 0, len(path); i < l; i++ {
+ if path[i] == ':' {
+ j := i + 1
+
+ r.insert(method, path[:i], nil, skind, "", nil)
+ for ; i < l && path[i] != '/'; i++ {
+ }
+
+ pnames = append(pnames, path[j:i])
+ path = path[:j] + path[i:]
+ i, l = j, len(path)
+
+ if i == l {
+ r.insert(method, path[:i], h, pkind, ppath, pnames)
+ return
+ }
+ r.insert(method, path[:i], nil, pkind, ppath, pnames)
+ } else if path[i] == '*' {
+ r.insert(method, path[:i], nil, skind, "", nil)
+ pnames = append(pnames, "*")
+ r.insert(method, path[:i+1], h, akind, ppath, pnames)
+ return
+ }
+ }
+
+ r.insert(method, path, h, skind, ppath, pnames)
+}
+
+func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string, pnames []string) {
+ // Adjust max param
+ l := len(pnames)
+ if *r.echo.maxParam < l {
+ *r.echo.maxParam = l
+ }
+
+ cn := r.tree // Current node as root
+ if cn == nil {
+ panic("echo: invalid method")
+ }
+ search := path
+
+ for {
+ sl := len(search)
+ pl := len(cn.prefix)
+ l := 0
+
+ // LCP
+ max := pl
+ if sl < max {
+ max = sl
+ }
+ for ; l < max && search[l] == cn.prefix[l]; l++ {
+ }
+
+ if l == 0 {
+ // At root node
+ cn.label = search[0]
+ cn.prefix = search
+ if h != nil {
+ cn.kind = t
+ cn.addHandler(method, h)
+ cn.ppath = ppath
+ cn.pnames = pnames
+ }
+ } else if l < pl {
+ // Split node
+ n := newNode(cn.kind, cn.prefix[l:], cn, cn.children, cn.methodHandler, cn.ppath, cn.pnames)
+
+ // Reset parent node
+ cn.kind = skind
+ cn.label = cn.prefix[0]
+ cn.prefix = cn.prefix[:l]
+ cn.children = nil
+ cn.methodHandler = new(methodHandler)
+ cn.ppath = ""
+ cn.pnames = nil
+
+ cn.addChild(n)
+
+ if l == sl {
+ // At parent node
+ cn.kind = t
+ cn.addHandler(method, h)
+ cn.ppath = ppath
+ cn.pnames = pnames
+ } else {
+ // Create child node
+ n = newNode(t, search[l:], cn, nil, new(methodHandler), ppath, pnames)
+ n.addHandler(method, h)
+ cn.addChild(n)
+ }
+ } else if l < sl {
+ search = search[l:]
+ c := cn.findChildWithLabel(search[0])
+ if c != nil {
+ // Go deeper
+ cn = c
+ continue
+ }
+ // Create child node
+ n := newNode(t, search, cn, nil, new(methodHandler), ppath, pnames)
+ n.addHandler(method, h)
+ cn.addChild(n)
+ } else {
+ // Node already exists
+ if h != nil {
+ cn.addHandler(method, h)
+ cn.ppath = ppath
+ if len(cn.pnames) == 0 { // Issue #729
+ cn.pnames = pnames
+ }
+ }
+ }
+ return
+ }
+}
+
+func newNode(t kind, pre string, p *node, c children, mh *methodHandler, ppath string, pnames []string) *node {
+ return &node{
+ kind: t,
+ label: pre[0],
+ prefix: pre,
+ parent: p,
+ children: c,
+ ppath: ppath,
+ pnames: pnames,
+ methodHandler: mh,
+ }
+}
+
+func (n *node) addChild(c *node) {
+ n.children = append(n.children, c)
+}
+
+func (n *node) findChild(l byte, t kind) *node {
+ for _, c := range n.children {
+ if c.label == l && c.kind == t {
+ return c
+ }
+ }
+ return nil
+}
+
+func (n *node) findChildWithLabel(l byte) *node {
+ for _, c := range n.children {
+ if c.label == l {
+ return c
+ }
+ }
+ return nil
+}
+
+func (n *node) findChildByKind(t kind) *node {
+ for _, c := range n.children {
+ if c.kind == t {
+ return c
+ }
+ }
+ return nil
+}
+
+func (n *node) addHandler(method string, h HandlerFunc) {
+ switch method {
+ case CONNECT:
+ n.methodHandler.connect = h
+ case DELETE:
+ n.methodHandler.delete = h
+ case GET:
+ n.methodHandler.get = h
+ case HEAD:
+ n.methodHandler.head = h
+ case OPTIONS:
+ n.methodHandler.options = h
+ case PATCH:
+ n.methodHandler.patch = h
+ case POST:
+ n.methodHandler.post = h
+ case PROPFIND:
+ n.methodHandler.propfind = h
+ case PUT:
+ n.methodHandler.put = h
+ case TRACE:
+ n.methodHandler.trace = h
+ }
+}
+
+func (n *node) findHandler(method string) HandlerFunc {
+ switch method {
+ case CONNECT:
+ return n.methodHandler.connect
+ case DELETE:
+ return n.methodHandler.delete
+ case GET:
+ return n.methodHandler.get
+ case HEAD:
+ return n.methodHandler.head
+ case OPTIONS:
+ return n.methodHandler.options
+ case PATCH:
+ return n.methodHandler.patch
+ case POST:
+ return n.methodHandler.post
+ case PROPFIND:
+ return n.methodHandler.propfind
+ case PUT:
+ return n.methodHandler.put
+ case TRACE:
+ return n.methodHandler.trace
+ default:
+ return nil
+ }
+}
+
+func (n *node) checkMethodNotAllowed() HandlerFunc {
+ for _, m := range methods {
+ if h := n.findHandler(m); h != nil {
+ return MethodNotAllowedHandler
+ }
+ }
+ return NotFoundHandler
+}
+
+// Find lookup a handler registered for method and path. It also parses URL for path
+// parameters and load them into context.
+//
+// For performance:
+//
+// - Get context from `Echo#AcquireContext()`
+// - Reset it `Context#Reset()`
+// - Return it `Echo#ReleaseContext()`.
+func (r *Router) Find(method, path string, c Context) {
+ ctx := c.(*context)
+ ctx.path = path
+ cn := r.tree // Current node as root
+
+ var (
+ search = path
+ child *node // Child node
+ n int // Param counter
+ nk kind // Next kind
+ nn *node // Next node
+ ns string // Next search
+ pvalues = ctx.pvalues // Use the internal slice so the interface can keep the illusion of a dynamic slice
+ )
+
+ // Search order static > param > any
+ for {
+ if search == "" {
+ goto End
+ }
+
+ pl := 0 // Prefix length
+ l := 0 // LCP length
+
+ if cn.label != ':' {
+ sl := len(search)
+ pl = len(cn.prefix)
+
+ // LCP
+ max := pl
+ if sl < max {
+ max = sl
+ }
+ for ; l < max && search[l] == cn.prefix[l]; l++ {
+ }
+ }
+
+ if l == pl {
+ // Continue search
+ search = search[l:]
+ } else {
+ cn = nn
+ search = ns
+ if nk == pkind {
+ goto Param
+ } else if nk == akind {
+ goto Any
+ }
+ // Not found
+ return
+ }
+
+ if search == "" {
+ goto End
+ }
+
+ // Static node
+ if child = cn.findChild(search[0], skind); child != nil {
+ // Save next
+ if cn.prefix[len(cn.prefix)-1] == '/' { // Issue #623
+ nk = pkind
+ nn = cn
+ ns = search
+ }
+ cn = child
+ continue
+ }
+
+ // Param node
+ Param:
+ if child = cn.findChildByKind(pkind); child != nil {
+ // Issue #378
+ if len(pvalues) == n {
+ continue
+ }
+
+ // Save next
+ if cn.prefix[len(cn.prefix)-1] == '/' { // Issue #623
+ nk = akind
+ nn = cn
+ ns = search
+ }
+
+ cn = child
+ i, l := 0, len(search)
+ for ; i < l && search[i] != '/'; i++ {
+ }
+ pvalues[n] = search[:i]
+ n++
+ search = search[i:]
+ continue
+ }
+
+ // Any node
+ Any:
+ if cn = cn.findChildByKind(akind); cn == nil {
+ if nn != nil {
+ cn = nn
+ nn = cn.parent // Next (Issue #954)
+ search = ns
+ if nk == pkind {
+ goto Param
+ } else if nk == akind {
+ goto Any
+ }
+ }
+ // Not found
+ return
+ }
+ pvalues[len(cn.pnames)-1] = search
+ goto End
+ }
+
+End:
+ ctx.handler = cn.findHandler(method)
+ ctx.path = cn.ppath
+ ctx.pnames = cn.pnames
+
+ // NOTE: Slow zone...
+ if ctx.handler == nil {
+ ctx.handler = cn.checkMethodNotAllowed()
+
+ // Dig further for any, might have an empty value for *, e.g.
+ // serving a directory. Issue #207.
+ if cn = cn.findChildByKind(akind); cn == nil {
+ return
+ }
+ if h := cn.findHandler(method); h != nil {
+ ctx.handler = h
+ } else {
+ ctx.handler = cn.checkMethodNotAllowed()
+ }
+ ctx.path = cn.ppath
+ ctx.pnames = cn.pnames
+ pvalues[len(cn.pnames)-1] = ""
+ }
+
+ return
+}
diff --git a/src/dma/vendor/github.com/labstack/gommon/LICENSE b/src/dma/vendor/github.com/labstack/gommon/LICENSE
new file mode 100644
index 00000000..d2ae3edf
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 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
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/src/dma/vendor/github.com/labstack/gommon/color/README.md b/src/dma/vendor/github.com/labstack/gommon/color/README.md
new file mode 100644
index 00000000..297c3518
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/color/README.md
@@ -0,0 +1,86 @@
+# Color
+
+Style terminal text.
+
+## Installation
+
+```sh
+go get github.com/labstack/gommon/color
+```
+
+## Windows?
+
+Try [cmder](http://bliker.github.io/cmder) or https://github.com/mattn/go-colorable
+
+## [Usage](https://github.com/labstack/gommon/blob/master/color/color_test.go)
+
+```sh
+import github.com/labstack/gommon/color
+```
+
+### Colored text
+
+```go
+color.Println(color.Black("black"))
+color.Println(color.Red("red"))
+color.Println(color.Green("green"))
+color.Println(color.Yellow("yellow"))
+color.Println(color.Blue("blue"))
+color.Println(color.Magenta("magenta"))
+color.Println(color.Cyan("cyan"))
+color.Println(color.White("white"))
+color.Println(color.Grey("grey"))
+```
+![Colored Text](http://i.imgur.com/8RtY1QR.png)
+
+### Colored background
+
+```go
+color.Println(color.BlackBg("black background", color.Wht))
+color.Println(color.RedBg("red background"))
+color.Println(color.GreenBg("green background"))
+color.Println(color.YellowBg("yellow background"))
+color.Println(color.BlueBg("blue background"))
+color.Println(color.MagentaBg("magenta background"))
+color.Println(color.CyanBg("cyan background"))
+color.Println(color.WhiteBg("white background"))
+```
+![Colored Background](http://i.imgur.com/SrrS6lw.png)
+
+### Emphasis
+
+```go
+color.Println(color.Bold("bold"))
+color.Println(color.Dim("dim"))
+color.Println(color.Italic("italic"))
+color.Println(color.Underline("underline"))
+color.Println(color.Inverse("inverse"))
+color.Println(color.Hidden("hidden"))
+color.Println(color.Strikeout("strikeout"))
+```
+![Emphasis](http://i.imgur.com/3RSJBbc.png)
+
+### Mix and match
+
+```go
+color.Println(color.Green("bold green with white background", color.B, color.WhtBg))
+color.Println(color.Red("underline red", color.U))
+color.Println(color.Yellow("dim yellow", color.D))
+color.Println(color.Cyan("inverse cyan", color.In))
+color.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))
+```
+![Mix and match](http://i.imgur.com/jWGq9Ca.png)
+
+### Enable/Disable the package
+
+```go
+color.Disable()
+color.Enable()
+```
+
+### New instance
+
+```go
+c := New()
+c.Green("green")
+```
diff --git a/src/dma/vendor/github.com/labstack/gommon/color/color.go b/src/dma/vendor/github.com/labstack/gommon/color/color.go
new file mode 100644
index 00000000..4131dcf3
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/color/color.go
@@ -0,0 +1,407 @@
+package color
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+
+ "github.com/mattn/go-colorable"
+ "github.com/mattn/go-isatty"
+)
+
+type (
+ inner func(interface{}, []string, *Color) string
+)
+
+// Color styles
+const (
+ // Blk Black text style
+ Blk = "30"
+ // Rd red text style
+ Rd = "31"
+ // Grn green text style
+ Grn = "32"
+ // Yel yellow text style
+ Yel = "33"
+ // Blu blue text style
+ Blu = "34"
+ // Mgn magenta text style
+ Mgn = "35"
+ // Cyn cyan text style
+ Cyn = "36"
+ // Wht white text style
+ Wht = "37"
+ // Gry grey text style
+ Gry = "90"
+
+ // BlkBg black background style
+ BlkBg = "40"
+ // RdBg red background style
+ RdBg = "41"
+ // GrnBg green background style
+ GrnBg = "42"
+ // YelBg yellow background style
+ YelBg = "43"
+ // BluBg blue background style
+ BluBg = "44"
+ // MgnBg magenta background style
+ MgnBg = "45"
+ // CynBg cyan background style
+ CynBg = "46"
+ // WhtBg white background style
+ WhtBg = "47"
+
+ // R reset emphasis style
+ R = "0"
+ // B bold emphasis style
+ B = "1"
+ // D dim emphasis style
+ D = "2"
+ // I italic emphasis style
+ I = "3"
+ // U underline emphasis style
+ U = "4"
+ // In inverse emphasis style
+ In = "7"
+ // H hidden emphasis style
+ H = "8"
+ // S strikeout emphasis style
+ S = "9"
+)
+
+var (
+ black = outer(Blk)
+ red = outer(Rd)
+ green = outer(Grn)
+ yellow = outer(Yel)
+ blue = outer(Blu)
+ magenta = outer(Mgn)
+ cyan = outer(Cyn)
+ white = outer(Wht)
+ grey = outer(Gry)
+
+ blackBg = outer(BlkBg)
+ redBg = outer(RdBg)
+ greenBg = outer(GrnBg)
+ yellowBg = outer(YelBg)
+ blueBg = outer(BluBg)
+ magentaBg = outer(MgnBg)
+ cyanBg = outer(CynBg)
+ whiteBg = outer(WhtBg)
+
+ reset = outer(R)
+ bold = outer(B)
+ dim = outer(D)
+ italic = outer(I)
+ underline = outer(U)
+ inverse = outer(In)
+ hidden = outer(H)
+ strikeout = outer(S)
+
+ global = New()
+)
+
+func outer(n string) inner {
+ return func(msg interface{}, styles []string, c *Color) string {
+ // TODO: Drop fmt to boost performance?
+ if c.disabled {
+ return fmt.Sprintf("%v", msg)
+ }
+
+ b := new(bytes.Buffer)
+ b.WriteString("\x1b[")
+ b.WriteString(n)
+ for _, s := range styles {
+ b.WriteString(";")
+ b.WriteString(s)
+ }
+ b.WriteString("m")
+ return fmt.Sprintf("%s%v\x1b[0m", b.String(), msg)
+ }
+}
+
+type (
+ Color struct {
+ output io.Writer
+ disabled bool
+ }
+)
+
+// New creates a Color instance.
+func New() (c *Color) {
+ c = new(Color)
+ c.SetOutput(colorable.NewColorableStdout())
+ return
+}
+
+// Output returns the output.
+func (c *Color) Output() io.Writer {
+ return c.output
+}
+
+// SetOutput sets the output.
+func (c *Color) SetOutput(w io.Writer) {
+ c.output = w
+ if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
+ c.disabled = true
+ }
+}
+
+// Disable disables the colors and styles.
+func (c *Color) Disable() {
+ c.disabled = true
+}
+
+// Enable enables the colors and styles.
+func (c *Color) Enable() {
+ c.disabled = false
+}
+
+// Print is analogous to `fmt.Print` with termial detection.
+func (c *Color) Print(args ...interface{}) {
+ fmt.Fprint(c.output, args...)
+}
+
+// Println is analogous to `fmt.Println` with termial detection.
+func (c *Color) Println(args ...interface{}) {
+ fmt.Fprintln(c.output, args...)
+}
+
+// Printf is analogous to `fmt.Printf` with termial detection.
+func (c *Color) Printf(format string, args ...interface{}) {
+ fmt.Fprintf(c.output, format, args...)
+}
+
+func (c *Color) Black(msg interface{}, styles ...string) string {
+ return black(msg, styles, c)
+}
+
+func (c *Color) Red(msg interface{}, styles ...string) string {
+ return red(msg, styles, c)
+}
+
+func (c *Color) Green(msg interface{}, styles ...string) string {
+ return green(msg, styles, c)
+}
+
+func (c *Color) Yellow(msg interface{}, styles ...string) string {
+ return yellow(msg, styles, c)
+}
+
+func (c *Color) Blue(msg interface{}, styles ...string) string {
+ return blue(msg, styles, c)
+}
+
+func (c *Color) Magenta(msg interface{}, styles ...string) string {
+ return magenta(msg, styles, c)
+}
+
+func (c *Color) Cyan(msg interface{}, styles ...string) string {
+ return cyan(msg, styles, c)
+}
+
+func (c *Color) White(msg interface{}, styles ...string) string {
+ return white(msg, styles, c)
+}
+
+func (c *Color) Grey(msg interface{}, styles ...string) string {
+ return grey(msg, styles, c)
+}
+
+func (c *Color) BlackBg(msg interface{}, styles ...string) string {
+ return blackBg(msg, styles, c)
+}
+
+func (c *Color) RedBg(msg interface{}, styles ...string) string {
+ return redBg(msg, styles, c)
+}
+
+func (c *Color) GreenBg(msg interface{}, styles ...string) string {
+ return greenBg(msg, styles, c)
+}
+
+func (c *Color) YellowBg(msg interface{}, styles ...string) string {
+ return yellowBg(msg, styles, c)
+}
+
+func (c *Color) BlueBg(msg interface{}, styles ...string) string {
+ return blueBg(msg, styles, c)
+}
+
+func (c *Color) MagentaBg(msg interface{}, styles ...string) string {
+ return magentaBg(msg, styles, c)
+}
+
+func (c *Color) CyanBg(msg interface{}, styles ...string) string {
+ return cyanBg(msg, styles, c)
+}
+
+func (c *Color) WhiteBg(msg interface{}, styles ...string) string {
+ return whiteBg(msg, styles, c)
+}
+
+func (c *Color) Reset(msg interface{}, styles ...string) string {
+ return reset(msg, styles, c)
+}
+
+func (c *Color) Bold(msg interface{}, styles ...string) string {
+ return bold(msg, styles, c)
+}
+
+func (c *Color) Dim(msg interface{}, styles ...string) string {
+ return dim(msg, styles, c)
+}
+
+func (c *Color) Italic(msg interface{}, styles ...string) string {
+ return italic(msg, styles, c)
+}
+
+func (c *Color) Underline(msg interface{}, styles ...string) string {
+ return underline(msg, styles, c)
+}
+
+func (c *Color) Inverse(msg interface{}, styles ...string) string {
+ return inverse(msg, styles, c)
+}
+
+func (c *Color) Hidden(msg interface{}, styles ...string) string {
+ return hidden(msg, styles, c)
+}
+
+func (c *Color) Strikeout(msg interface{}, styles ...string) string {
+ return strikeout(msg, styles, c)
+}
+
+// Output returns the output.
+func Output() io.Writer {
+ return global.output
+}
+
+// SetOutput sets the output.
+func SetOutput(w io.Writer) {
+ global.SetOutput(w)
+}
+
+func Disable() {
+ global.Disable()
+}
+
+func Enable() {
+ global.Enable()
+}
+
+// Print is analogous to `fmt.Print` with termial detection.
+func Print(args ...interface{}) {
+ global.Print(args...)
+}
+
+// Println is analogous to `fmt.Println` with termial detection.
+func Println(args ...interface{}) {
+ global.Println(args...)
+}
+
+// Printf is analogous to `fmt.Printf` with termial detection.
+func Printf(format string, args ...interface{}) {
+ global.Printf(format, args...)
+}
+
+func Black(msg interface{}, styles ...string) string {
+ return global.Black(msg, styles...)
+}
+
+func Red(msg interface{}, styles ...string) string {
+ return global.Red(msg, styles...)
+}
+
+func Green(msg interface{}, styles ...string) string {
+ return global.Green(msg, styles...)
+}
+
+func Yellow(msg interface{}, styles ...string) string {
+ return global.Yellow(msg, styles...)
+}
+
+func Blue(msg interface{}, styles ...string) string {
+ return global.Blue(msg, styles...)
+}
+
+func Magenta(msg interface{}, styles ...string) string {
+ return global.Magenta(msg, styles...)
+}
+
+func Cyan(msg interface{}, styles ...string) string {
+ return global.Cyan(msg, styles...)
+}
+
+func White(msg interface{}, styles ...string) string {
+ return global.White(msg, styles...)
+}
+
+func Grey(msg interface{}, styles ...string) string {
+ return global.Grey(msg, styles...)
+}
+
+func BlackBg(msg interface{}, styles ...string) string {
+ return global.BlackBg(msg, styles...)
+}
+
+func RedBg(msg interface{}, styles ...string) string {
+ return global.RedBg(msg, styles...)
+}
+
+func GreenBg(msg interface{}, styles ...string) string {
+ return global.GreenBg(msg, styles...)
+}
+
+func YellowBg(msg interface{}, styles ...string) string {
+ return global.YellowBg(msg, styles...)
+}
+
+func BlueBg(msg interface{}, styles ...string) string {
+ return global.BlueBg(msg, styles...)
+}
+
+func MagentaBg(msg interface{}, styles ...string) string {
+ return global.MagentaBg(msg, styles...)
+}
+
+func CyanBg(msg interface{}, styles ...string) string {
+ return global.CyanBg(msg, styles...)
+}
+
+func WhiteBg(msg interface{}, styles ...string) string {
+ return global.WhiteBg(msg, styles...)
+}
+
+func Reset(msg interface{}, styles ...string) string {
+ return global.Reset(msg, styles...)
+}
+
+func Bold(msg interface{}, styles ...string) string {
+ return global.Bold(msg, styles...)
+}
+
+func Dim(msg interface{}, styles ...string) string {
+ return global.Dim(msg, styles...)
+}
+
+func Italic(msg interface{}, styles ...string) string {
+ return global.Italic(msg, styles...)
+}
+
+func Underline(msg interface{}, styles ...string) string {
+ return global.Underline(msg, styles...)
+}
+
+func Inverse(msg interface{}, styles ...string) string {
+ return global.Inverse(msg, styles...)
+}
+
+func Hidden(msg interface{}, styles ...string) string {
+ return global.Hidden(msg, styles...)
+}
+
+func Strikeout(msg interface{}, styles ...string) string {
+ return global.Strikeout(msg, styles...)
+}
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/README.md b/src/dma/vendor/github.com/labstack/gommon/log/README.md
new file mode 100644
index 00000000..d5b9e9f0
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/README.md
@@ -0,0 +1,5 @@
+## WORK IN PROGRESS
+
+### Usage
+
+[log_test.go](log_test.go)
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/color.go b/src/dma/vendor/github.com/labstack/gommon/log/color.go
new file mode 100644
index 00000000..7351b39c
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/color.go
@@ -0,0 +1,13 @@
+// +build !appengine
+
+package log
+
+import (
+ "io"
+
+ "github.com/mattn/go-colorable"
+)
+
+func output() io.Writer {
+ return colorable.NewColorableStdout()
+}
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/log.go b/src/dma/vendor/github.com/labstack/gommon/log/log.go
new file mode 100644
index 00000000..0d77a87a
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/log.go
@@ -0,0 +1,415 @@
+package log
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "os"
+ "path"
+ "runtime"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/mattn/go-isatty"
+ "github.com/valyala/fasttemplate"
+
+ "github.com/labstack/gommon/color"
+)
+
+type (
+ Logger struct {
+ prefix string
+ level Lvl
+ skip int
+ output io.Writer
+ template *fasttemplate.Template
+ levels []string
+ color *color.Color
+ bufferPool sync.Pool
+ mutex sync.Mutex
+ }
+
+ Lvl uint8
+
+ JSON map[string]interface{}
+)
+
+const (
+ DEBUG Lvl = iota + 1
+ INFO
+ WARN
+ ERROR
+ OFF
+ panicLevel
+ fatalLevel
+)
+
+var (
+ global = New("-")
+ defaultHeader = `{"time":"${time_rfc3339_nano}","level":"${level}","prefix":"${prefix}",` +
+ `"file":"${short_file}","line":"${line}"}`
+)
+
+func init() {
+ global.skip = 3
+}
+
+func New(prefix string) (l *Logger) {
+ l = &Logger{
+ level: INFO,
+ skip: 2,
+ prefix: prefix,
+ template: l.newTemplate(defaultHeader),
+ color: color.New(),
+ bufferPool: sync.Pool{
+ New: func() interface{} {
+ return bytes.NewBuffer(make([]byte, 256))
+ },
+ },
+ }
+ l.initLevels()
+ l.SetOutput(output())
+ return
+}
+
+func (l *Logger) initLevels() {
+ l.levels = []string{
+ "-",
+ l.color.Blue("DEBUG"),
+ l.color.Green("INFO"),
+ l.color.Yellow("WARN"),
+ l.color.Red("ERROR"),
+ "",
+ l.color.Yellow("PANIC", color.U),
+ l.color.Red("FATAL", color.U),
+ }
+}
+
+func (l *Logger) newTemplate(format string) *fasttemplate.Template {
+ return fasttemplate.New(format, "${", "}")
+}
+
+func (l *Logger) DisableColor() {
+ l.color.Disable()
+ l.initLevels()
+}
+
+func (l *Logger) EnableColor() {
+ l.color.Enable()
+ l.initLevels()
+}
+
+func (l *Logger) Prefix() string {
+ return l.prefix
+}
+
+func (l *Logger) SetPrefix(p string) {
+ l.prefix = p
+}
+
+func (l *Logger) Level() Lvl {
+ return l.level
+}
+
+func (l *Logger) SetLevel(v Lvl) {
+ l.level = v
+}
+
+func (l *Logger) Output() io.Writer {
+ return l.output
+}
+
+func (l *Logger) SetOutput(w io.Writer) {
+ l.output = w
+ if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
+ l.DisableColor()
+ }
+}
+
+func (l *Logger) Color() *color.Color {
+ return l.color
+}
+
+func (l *Logger) SetHeader(h string) {
+ l.template = l.newTemplate(h)
+}
+
+func (l *Logger) Print(i ...interface{}) {
+ l.log(0, "", i...)
+ // fmt.Fprintln(l.output, i...)
+}
+
+func (l *Logger) Printf(format string, args ...interface{}) {
+ l.log(0, format, args...)
+}
+
+func (l *Logger) Printj(j JSON) {
+ l.log(0, "json", j)
+}
+
+func (l *Logger) Debug(i ...interface{}) {
+ l.log(DEBUG, "", i...)
+}
+
+func (l *Logger) Debugf(format string, args ...interface{}) {
+ l.log(DEBUG, format, args...)
+}
+
+func (l *Logger) Debugj(j JSON) {
+ l.log(DEBUG, "json", j)
+}
+
+func (l *Logger) Info(i ...interface{}) {
+ l.log(INFO, "", i...)
+}
+
+func (l *Logger) Infof(format string, args ...interface{}) {
+ l.log(INFO, format, args...)
+}
+
+func (l *Logger) Infoj(j JSON) {
+ l.log(INFO, "json", j)
+}
+
+func (l *Logger) Warn(i ...interface{}) {
+ l.log(WARN, "", i...)
+}
+
+func (l *Logger) Warnf(format string, args ...interface{}) {
+ l.log(WARN, format, args...)
+}
+
+func (l *Logger) Warnj(j JSON) {
+ l.log(WARN, "json", j)
+}
+
+func (l *Logger) Error(i ...interface{}) {
+ l.log(ERROR, "", i...)
+}
+
+func (l *Logger) Errorf(format string, args ...interface{}) {
+ l.log(ERROR, format, args...)
+}
+
+func (l *Logger) Errorj(j JSON) {
+ l.log(ERROR, "json", j)
+}
+
+func (l *Logger) Fatal(i ...interface{}) {
+ l.log(fatalLevel, "", i...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalf(format string, args ...interface{}) {
+ l.log(fatalLevel, format, args...)
+ os.Exit(1)
+}
+
+func (l *Logger) Fatalj(j JSON) {
+ l.log(fatalLevel, "json", j)
+ os.Exit(1)
+}
+
+func (l *Logger) Panic(i ...interface{}) {
+ l.log(panicLevel, "", i...)
+ panic(fmt.Sprint(i...))
+}
+
+func (l *Logger) Panicf(format string, args ...interface{}) {
+ l.log(panicLevel, format, args...)
+ panic(fmt.Sprintf(format, args))
+}
+
+func (l *Logger) Panicj(j JSON) {
+ l.log(panicLevel, "json", j)
+ panic(j)
+}
+
+func DisableColor() {
+ global.DisableColor()
+}
+
+func EnableColor() {
+ global.EnableColor()
+}
+
+func Prefix() string {
+ return global.Prefix()
+}
+
+func SetPrefix(p string) {
+ global.SetPrefix(p)
+}
+
+func Level() Lvl {
+ return global.Level()
+}
+
+func SetLevel(v Lvl) {
+ global.SetLevel(v)
+}
+
+func Output() io.Writer {
+ return global.Output()
+}
+
+func SetOutput(w io.Writer) {
+ global.SetOutput(w)
+}
+
+func SetHeader(h string) {
+ global.SetHeader(h)
+}
+
+func Print(i ...interface{}) {
+ global.Print(i...)
+}
+
+func Printf(format string, args ...interface{}) {
+ global.Printf(format, args...)
+}
+
+func Printj(j JSON) {
+ global.Printj(j)
+}
+
+func Debug(i ...interface{}) {
+ global.Debug(i...)
+}
+
+func Debugf(format string, args ...interface{}) {
+ global.Debugf(format, args...)
+}
+
+func Debugj(j JSON) {
+ global.Debugj(j)
+}
+
+func Info(i ...interface{}) {
+ global.Info(i...)
+}
+
+func Infof(format string, args ...interface{}) {
+ global.Infof(format, args...)
+}
+
+func Infoj(j JSON) {
+ global.Infoj(j)
+}
+
+func Warn(i ...interface{}) {
+ global.Warn(i...)
+}
+
+func Warnf(format string, args ...interface{}) {
+ global.Warnf(format, args...)
+}
+
+func Warnj(j JSON) {
+ global.Warnj(j)
+}
+
+func Error(i ...interface{}) {
+ global.Error(i...)
+}
+
+func Errorf(format string, args ...interface{}) {
+ global.Errorf(format, args...)
+}
+
+func Errorj(j JSON) {
+ global.Errorj(j)
+}
+
+func Fatal(i ...interface{}) {
+ global.Fatal(i...)
+}
+
+func Fatalf(format string, args ...interface{}) {
+ global.Fatalf(format, args...)
+}
+
+func Fatalj(j JSON) {
+ global.Fatalj(j)
+}
+
+func Panic(i ...interface{}) {
+ global.Panic(i...)
+}
+
+func Panicf(format string, args ...interface{}) {
+ global.Panicf(format, args...)
+}
+
+func Panicj(j JSON) {
+ global.Panicj(j)
+}
+
+func (l *Logger) log(v Lvl, format string, args ...interface{}) {
+ l.mutex.Lock()
+ defer l.mutex.Unlock()
+ buf := l.bufferPool.Get().(*bytes.Buffer)
+ buf.Reset()
+ defer l.bufferPool.Put(buf)
+ _, file, line, _ := runtime.Caller(l.skip)
+
+ if v >= l.level || v == 0 {
+ message := ""
+ if format == "" {
+ message = fmt.Sprint(args...)
+ } else if format == "json" {
+ b, err := json.Marshal(args[0])
+ if err != nil {
+ panic(err)
+ }
+ message = string(b)
+ } else {
+ message = fmt.Sprintf(format, args...)
+ }
+
+ _, err := l.template.ExecuteFunc(buf, func(w io.Writer, tag string) (int, error) {
+ switch tag {
+ case "time_rfc3339":
+ return w.Write([]byte(time.Now().Format(time.RFC3339)))
+ case "time_rfc3339_nano":
+ return w.Write([]byte(time.Now().Format(time.RFC3339Nano)))
+ case "level":
+ return w.Write([]byte(l.levels[v]))
+ case "prefix":
+ return w.Write([]byte(l.prefix))
+ case "long_file":
+ return w.Write([]byte(file))
+ case "short_file":
+ return w.Write([]byte(path.Base(file)))
+ case "line":
+ return w.Write([]byte(strconv.Itoa(line)))
+ }
+ return 0, nil
+ })
+
+ if err == nil {
+ s := buf.String()
+ i := buf.Len() - 1
+ if s[i] == '}' {
+ // JSON header
+ buf.Truncate(i)
+ buf.WriteByte(',')
+ if format == "json" {
+ buf.WriteString(message[1:])
+ } else {
+ buf.WriteString(`"message":`)
+ buf.WriteString(strconv.Quote(message))
+ buf.WriteString(`}`)
+ }
+ } else {
+ // Text header
+ buf.WriteByte(' ')
+ buf.WriteString(message)
+ }
+ buf.WriteByte('\n')
+ l.output.Write(buf.Bytes())
+ }
+ }
+}
diff --git a/src/dma/vendor/github.com/labstack/gommon/log/white.go b/src/dma/vendor/github.com/labstack/gommon/log/white.go
new file mode 100644
index 00000000..746cc562
--- /dev/null
+++ b/src/dma/vendor/github.com/labstack/gommon/log/white.go
@@ -0,0 +1,12 @@
+// +build appengine
+
+package log
+
+import (
+ "io"
+ "os"
+)
+
+func output() io.Writer {
+ return os.Stdout
+}