From c81c0dd22a7779148c4890cfd4bbf490054f06f1 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 31 Jan 2019 17:06:36 +0100 Subject: Update vendor, move to labstack/echo/v4 Fixes #698 --- bridge/api/api.go | 22 +- go.mod | 29 +- go.sum | 83 +- vendor/github.com/dgrijalva/jwt-go/README.md | 31 +- .../github.com/dgrijalva/jwt-go/VERSION_HISTORY.md | 13 + vendor/github.com/dgrijalva/jwt-go/ecdsa.go | 1 + vendor/github.com/dgrijalva/jwt-go/hmac.go | 3 +- vendor/github.com/dgrijalva/jwt-go/parser.go | 113 +- vendor/github.com/dgrijalva/jwt-go/rsa.go | 5 +- vendor/github.com/dgrijalva/jwt-go/rsa_utils.go | 32 + vendor/github.com/kardianos/osext/osext_go18.go | 2 +- vendor/github.com/kardianos/osext/osext_procfs.go | 4 +- vendor/github.com/kardianos/osext/osext_sysctl.go | 2 +- vendor/github.com/labstack/echo/.editorconfig | 25 - vendor/github.com/labstack/echo/.gitattributes | 20 - vendor/github.com/labstack/echo/.gitignore | 7 - vendor/github.com/labstack/echo/.travis.yml | 14 - vendor/github.com/labstack/echo/Gopkg.lock | 75 - vendor/github.com/labstack/echo/Gopkg.toml | 42 - vendor/github.com/labstack/echo/LICENSE | 21 - vendor/github.com/labstack/echo/Makefile | 17 - vendor/github.com/labstack/echo/README.md | 99 - vendor/github.com/labstack/echo/bind.go | 261 -- vendor/github.com/labstack/echo/context.go | 576 --- vendor/github.com/labstack/echo/echo.go | 781 ---- vendor/github.com/labstack/echo/group.go | 120 - vendor/github.com/labstack/echo/log.go | 40 - .../labstack/echo/middleware/basic_auth.go | 106 - .../labstack/echo/middleware/body_dump.go | 111 - .../labstack/echo/middleware/body_limit.go | 117 - .../labstack/echo/middleware/compress.go | 122 - vendor/github.com/labstack/echo/middleware/cors.go | 139 - vendor/github.com/labstack/echo/middleware/csrf.go | 210 - vendor/github.com/labstack/echo/middleware/jwt.go | 199 - .../labstack/echo/middleware/key_auth.go | 150 - .../github.com/labstack/echo/middleware/logger.go | 209 - .../labstack/echo/middleware/method_override.go | 88 - .../labstack/echo/middleware/middleware.go | 35 - .../github.com/labstack/echo/middleware/proxy.go | 252 -- .../github.com/labstack/echo/middleware/recover.go | 81 - .../labstack/echo/middleware/redirect.go | 153 - .../labstack/echo/middleware/request_id.go | 64 - .../github.com/labstack/echo/middleware/rewrite.go | 83 - .../github.com/labstack/echo/middleware/secure.go | 116 - .../github.com/labstack/echo/middleware/slash.go | 119 - .../github.com/labstack/echo/middleware/static.go | 229 -- vendor/github.com/labstack/echo/response.go | 110 - vendor/github.com/labstack/echo/router.go | 434 -- vendor/github.com/labstack/echo/v4/.editorconfig | 25 + vendor/github.com/labstack/echo/v4/.gitattributes | 20 + vendor/github.com/labstack/echo/v4/.gitignore | 7 + vendor/github.com/labstack/echo/v4/.travis.yml | 16 + vendor/github.com/labstack/echo/v4/LICENSE | 21 + vendor/github.com/labstack/echo/v4/Makefile | 3 + vendor/github.com/labstack/echo/v4/README.md | 114 + vendor/github.com/labstack/echo/v4/bind.go | 273 ++ vendor/github.com/labstack/echo/v4/context.go | 600 +++ vendor/github.com/labstack/echo/v4/echo.go | 782 ++++ vendor/github.com/labstack/echo/v4/go.mod | 13 + vendor/github.com/labstack/echo/v4/go.sum | 23 + vendor/github.com/labstack/echo/v4/group.go | 121 + vendor/github.com/labstack/echo/v4/log.go | 41 + .../labstack/echo/v4/middleware/basic_auth.go | 106 + .../labstack/echo/v4/middleware/body_dump.go | 107 + .../labstack/echo/v4/middleware/body_limit.go | 117 + .../labstack/echo/v4/middleware/compress.go | 118 + .../github.com/labstack/echo/v4/middleware/cors.go | 143 + .../github.com/labstack/echo/v4/middleware/csrf.go | 210 + .../github.com/labstack/echo/v4/middleware/jwt.go | 227 ++ .../labstack/echo/v4/middleware/key_auth.go | 150 + .../labstack/echo/v4/middleware/logger.go | 217 + .../labstack/echo/v4/middleware/method_override.go | 92 + .../labstack/echo/v4/middleware/middleware.go | 38 + .../labstack/echo/v4/middleware/proxy.go | 258 ++ .../labstack/echo/v4/middleware/proxy_1_11.go | 25 + .../labstack/echo/v4/middleware/proxy_1_11_n.go | 14 + .../labstack/echo/v4/middleware/recover.go | 81 + .../labstack/echo/v4/middleware/redirect.go | 153 + .../labstack/echo/v4/middleware/request_id.go | 64 + .../labstack/echo/v4/middleware/rewrite.go | 84 + .../labstack/echo/v4/middleware/secure.go | 116 + .../labstack/echo/v4/middleware/slash.go | 119 + .../labstack/echo/v4/middleware/static.go | 229 ++ vendor/github.com/labstack/echo/v4/response.go | 101 + vendor/github.com/labstack/echo/v4/router.go | 435 ++ vendor/github.com/labstack/gommon/LICENSE | 2 +- vendor/github.com/labstack/gommon/bytes/bytes.go | 68 +- vendor/github.com/labstack/gommon/log/log.go | 30 +- vendor/github.com/labstack/gommon/random/random.go | 14 +- vendor/github.com/mattn/go-colorable/.travis.yml | 7 +- vendor/github.com/mattn/go-colorable/README.md | 5 + .../mattn/go-colorable/colorable_appengine.go | 29 + .../mattn/go-colorable/colorable_others.go | 3 + .../mattn/go-colorable/colorable_windows.go | 204 +- .../github.com/mattn/go-colorable/noncolorable.go | 12 +- vendor/github.com/mattn/go-isatty/.travis.yml | 7 +- vendor/github.com/mattn/go-isatty/README.md | 5 +- .../github.com/mattn/go-isatty/isatty_appengine.go | 6 + vendor/github.com/mattn/go-isatty/isatty_linux.go | 2 +- .../mattn/go-isatty/isatty_linux_ppc64x.go | 19 + vendor/github.com/mattn/go-isatty/isatty_others.go | 5 +- vendor/github.com/nlopes/slack/.gometalinter.json | 14 + vendor/github.com/nlopes/slack/.travis.yml | 22 +- vendor/github.com/nlopes/slack/CHANGELOG.md | 5 + vendor/github.com/nlopes/slack/README.md | 12 +- vendor/github.com/nlopes/slack/channels.go | 50 +- vendor/github.com/nlopes/slack/chat.go | 26 +- vendor/github.com/nlopes/slack/dialog.go | 13 +- vendor/github.com/nlopes/slack/files.go | 22 + vendor/github.com/nlopes/slack/groups.go | 24 +- vendor/github.com/nlopes/slack/interactions.go | 1 + vendor/github.com/nlopes/slack/reminders.go | 75 + vendor/github.com/nlopes/slack/security.go | 6 +- vendor/github.com/nlopes/slack/slack.go | 3 +- vendor/github.com/nlopes/slack/users.go | 14 +- vendor/github.com/nlopes/slack/websocket.go | 4 +- .../github.com/peterhellberg/emojilib/.travis.yml | 9 +- vendor/github.com/peterhellberg/emojilib/LICENSE | 2 +- vendor/github.com/peterhellberg/emojilib/README.md | 2 +- .../shazow/ssh-chat/internal/sanitize/sanitize.go | 28 + vendor/github.com/shazow/ssh-chat/sshd/auth.go | 11 +- vendor/github.com/sirupsen/logrus/.travis.yml | 1 + vendor/github.com/sirupsen/logrus/README.md | 1 + vendor/github.com/sirupsen/logrus/entry.go | 125 +- vendor/github.com/sirupsen/logrus/logger.go | 152 +- vendor/github.com/sirupsen/logrus/logrus.go | 42 +- .../sirupsen/logrus/terminal_check_aix.go | 9 + .../sirupsen/logrus/terminal_check_notappengine.go | 2 +- .../github.com/sirupsen/logrus/text_formatter.go | 24 +- vendor/github.com/spf13/viper/.gitignore | 7 +- vendor/github.com/spf13/viper/.travis.yml | 6 +- vendor/github.com/spf13/viper/README.md | 7 +- vendor/github.com/spf13/viper/go.mod | 18 +- vendor/github.com/spf13/viper/go.sum | 45 +- vendor/github.com/spf13/viper/viper.go | 97 +- vendor/github.com/stretchr/testify/LICENSE | 35 +- .../stretchr/testify/assert/assertions.go | 32 +- vendor/github.com/zfjagann/golang-ring/ring.go | 65 +- vendor/golang.org/x/crypto/acme/acme.go | 16 +- .../golang.org/x/crypto/ssh/terminal/terminal.go | 4 + vendor/golang.org/x/crypto/ssh/terminal/util.go | 4 +- .../golang.org/x/crypto/ssh/terminal/util_aix.go | 12 + .../golang.org/x/crypto/ssh/terminal/util_plan9.go | 2 +- .../x/crypto/ssh/terminal/util_solaris.go | 2 +- .../x/crypto/ssh/terminal/util_windows.go | 2 +- vendor/golang.org/x/sys/unix/README.md | 4 +- vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s | 29 + vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s | 29 + vendor/golang.org/x/sys/unix/fcntl.go | 2 +- vendor/golang.org/x/sys/unix/fcntl_darwin.go | 18 + vendor/golang.org/x/sys/unix/mkall.sh | 76 +- vendor/golang.org/x/sys/unix/mkasm_darwin.go | 61 + vendor/golang.org/x/sys/unix/mkerrors.sh | 26 +- vendor/golang.org/x/sys/unix/mkpost.go | 6 +- vendor/golang.org/x/sys/unix/mksyscall.go | 398 ++ vendor/golang.org/x/sys/unix/mksyscall.pl | 341 -- vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go | 404 ++ vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.pl | 384 -- .../golang.org/x/sys/unix/mksyscall_aix_ppc64.go | 602 +++ .../golang.org/x/sys/unix/mksyscall_aix_ppc64.pl | 579 --- vendor/golang.org/x/sys/unix/mksysnum.go | 190 + vendor/golang.org/x/sys/unix/mksysnum_darwin.pl | 39 - vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl | 50 - vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl | 50 - vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl | 58 - vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl | 50 - vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 25 +- vendor/golang.org/x/sys/unix/syscall_aix.go | 18 +- vendor/golang.org/x/sys/unix/syscall_darwin.go | 62 +- vendor/golang.org/x/sys/unix/syscall_darwin_386.go | 23 +- .../golang.org/x/sys/unix/syscall_darwin_amd64.go | 23 +- vendor/golang.org/x/sys/unix/syscall_darwin_arm.go | 26 +- .../golang.org/x/sys/unix/syscall_darwin_arm64.go | 26 +- .../x/sys/unix/syscall_darwin_libSystem.go | 31 + vendor/golang.org/x/sys/unix/syscall_dragonfly.go | 8 + vendor/golang.org/x/sys/unix/syscall_freebsd.go | 7 + .../golang.org/x/sys/unix/syscall_freebsd_arm64.go | 52 + vendor/golang.org/x/sys/unix/syscall_linux.go | 35 +- vendor/golang.org/x/sys/unix/syscall_linux_386.go | 1 + .../golang.org/x/sys/unix/syscall_linux_amd64.go | 19 +- vendor/golang.org/x/sys/unix/syscall_linux_arm.go | 9 + .../golang.org/x/sys/unix/syscall_linux_arm64.go | 1 + .../golang.org/x/sys/unix/syscall_linux_mips64x.go | 10 +- .../golang.org/x/sys/unix/syscall_linux_mipsx.go | 1 + .../golang.org/x/sys/unix/syscall_linux_ppc64x.go | 1 + .../golang.org/x/sys/unix/syscall_linux_riscv64.go | 4 + .../golang.org/x/sys/unix/syscall_linux_s390x.go | 1 + .../golang.org/x/sys/unix/syscall_linux_sparc64.go | 1 + vendor/golang.org/x/sys/unix/syscall_netbsd.go | 7 + .../golang.org/x/sys/unix/syscall_netbsd_arm64.go | 33 + vendor/golang.org/x/sys/unix/syscall_openbsd.go | 7 + vendor/golang.org/x/sys/unix/syscall_solaris.go | 7 + vendor/golang.org/x/sys/unix/syscall_unix.go | 15 - .../golang.org/x/sys/unix/zerrors_freebsd_arm64.go | 1794 +++++++++ vendor/golang.org/x/sys/unix/zerrors_linux_386.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_amd64.go | 67 +- vendor/golang.org/x/sys/unix/zerrors_linux_arm.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_arm64.go | 67 +- vendor/golang.org/x/sys/unix/zerrors_linux_mips.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_mips64.go | 67 +- .../x/sys/unix/zerrors_linux_mips64le.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_mipsle.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_ppc64.go | 69 +- .../golang.org/x/sys/unix/zerrors_linux_ppc64le.go | 69 +- .../golang.org/x/sys/unix/zerrors_linux_riscv64.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_s390x.go | 67 +- .../golang.org/x/sys/unix/zerrors_linux_sparc64.go | 4225 ++++++++++++-------- .../golang.org/x/sys/unix/zerrors_netbsd_arm64.go | 1762 ++++++++ vendor/golang.org/x/sys/unix/zsyscall_aix_ppc.go | 2 +- vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go | 2 +- .../golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go | 2 +- .../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 2 +- .../x/sys/unix/zsyscall_darwin_386.1_11.go | 1810 +++++++++ .../golang.org/x/sys/unix/zsyscall_darwin_386.go | 1174 +++++- vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s | 284 ++ .../x/sys/unix/zsyscall_darwin_amd64.1_11.go | 1810 +++++++++ .../golang.org/x/sys/unix/zsyscall_darwin_amd64.go | 1174 +++++- .../golang.org/x/sys/unix/zsyscall_darwin_amd64.s | 284 ++ .../x/sys/unix/zsyscall_darwin_arm.1_11.go | 1793 +++++++++ .../golang.org/x/sys/unix/zsyscall_darwin_arm.go | 1152 +++++- vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s | 282 ++ .../x/sys/unix/zsyscall_darwin_arm64.1_11.go | 1793 +++++++++ .../golang.org/x/sys/unix/zsyscall_darwin_arm64.go | 1152 +++++- .../golang.org/x/sys/unix/zsyscall_darwin_arm64.s | 282 ++ .../x/sys/unix/zsyscall_dragonfly_amd64.go | 22 +- .../golang.org/x/sys/unix/zsyscall_freebsd_386.go | 2 +- .../x/sys/unix/zsyscall_freebsd_amd64.go | 2 +- .../golang.org/x/sys/unix/zsyscall_freebsd_arm.go | 2 +- .../x/sys/unix/zsyscall_freebsd_arm64.go | 2015 ++++++++++ vendor/golang.org/x/sys/unix/zsyscall_linux_386.go | 59 +- .../golang.org/x/sys/unix/zsyscall_linux_amd64.go | 76 +- vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go | 69 +- .../golang.org/x/sys/unix/zsyscall_linux_arm64.go | 59 +- .../golang.org/x/sys/unix/zsyscall_linux_mips.go | 59 +- .../golang.org/x/sys/unix/zsyscall_linux_mips64.go | 89 +- .../x/sys/unix/zsyscall_linux_mips64le.go | 89 +- .../golang.org/x/sys/unix/zsyscall_linux_mipsle.go | 59 +- .../golang.org/x/sys/unix/zsyscall_linux_ppc64.go | 59 +- .../x/sys/unix/zsyscall_linux_ppc64le.go | 59 +- .../x/sys/unix/zsyscall_linux_riscv64.go | 39 +- .../golang.org/x/sys/unix/zsyscall_linux_s390x.go | 59 +- .../x/sys/unix/zsyscall_linux_sparc64.go | 225 +- .../golang.org/x/sys/unix/zsyscall_netbsd_386.go | 2 +- .../golang.org/x/sys/unix/zsyscall_netbsd_amd64.go | 2 +- .../golang.org/x/sys/unix/zsyscall_netbsd_arm.go | 2 +- .../golang.org/x/sys/unix/zsyscall_netbsd_arm64.go | 1826 +++++++++ .../golang.org/x/sys/unix/zsyscall_openbsd_386.go | 2 +- .../x/sys/unix/zsyscall_openbsd_amd64.go | 2 +- .../golang.org/x/sys/unix/zsyscall_openbsd_arm.go | 2 +- vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go | 2 +- .../golang.org/x/sys/unix/zsysnum_darwin_amd64.go | 2 +- vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go | 2 +- .../golang.org/x/sys/unix/zsysnum_darwin_arm64.go | 2 +- .../x/sys/unix/zsysnum_dragonfly_amd64.go | 176 +- .../golang.org/x/sys/unix/zsysnum_freebsd_386.go | 452 +-- .../golang.org/x/sys/unix/zsysnum_freebsd_amd64.go | 452 +-- .../golang.org/x/sys/unix/zsysnum_freebsd_arm.go | 452 +-- .../golang.org/x/sys/unix/zsysnum_freebsd_arm64.go | 395 ++ vendor/golang.org/x/sys/unix/zsysnum_linux_386.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_amd64.go | 2 +- vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_arm64.go | 2 +- vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_mips64.go | 2 +- .../x/sys/unix/zsysnum_linux_mips64le.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_mipsle.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_ppc64.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_ppc64le.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_riscv64.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_s390x.go | 2 +- .../golang.org/x/sys/unix/zsysnum_linux_sparc64.go | 6 +- vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go | 4 +- .../golang.org/x/sys/unix/zsysnum_netbsd_amd64.go | 4 +- vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go | 4 +- .../golang.org/x/sys/unix/zsysnum_netbsd_arm64.go | 274 ++ .../golang.org/x/sys/unix/zsysnum_openbsd_386.go | 216 +- .../golang.org/x/sys/unix/zsysnum_openbsd_amd64.go | 216 +- .../golang.org/x/sys/unix/zsysnum_openbsd_arm.go | 216 +- .../golang.org/x/sys/unix/ztypes_freebsd_arm64.go | 602 +++ vendor/golang.org/x/sys/unix/ztypes_linux_386.go | 49 +- vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go | 56 +- vendor/golang.org/x/sys/unix/ztypes_linux_arm.go | 50 +- vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go | 56 +- vendor/golang.org/x/sys/unix/ztypes_linux_mips.go | 47 +- .../golang.org/x/sys/unix/ztypes_linux_mips64.go | 56 +- .../golang.org/x/sys/unix/ztypes_linux_mips64le.go | 56 +- .../golang.org/x/sys/unix/ztypes_linux_mipsle.go | 47 +- vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go | 56 +- .../golang.org/x/sys/unix/ztypes_linux_ppc64le.go | 56 +- .../golang.org/x/sys/unix/ztypes_linux_riscv64.go | 58 +- vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go | 61 +- .../golang.org/x/sys/unix/ztypes_linux_sparc64.go | 1527 ++++++- .../golang.org/x/sys/unix/ztypes_netbsd_arm64.go | 472 +++ vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go | 102 +- vendor/gopkg.in/yaml.v2/encode.go | 28 + vendor/modules.txt | 39 +- 296 files changed, 36870 insertions(+), 12063 deletions(-) delete mode 100644 vendor/github.com/labstack/echo/.editorconfig delete mode 100644 vendor/github.com/labstack/echo/.gitattributes delete mode 100644 vendor/github.com/labstack/echo/.gitignore delete mode 100644 vendor/github.com/labstack/echo/.travis.yml delete mode 100644 vendor/github.com/labstack/echo/Gopkg.lock delete mode 100644 vendor/github.com/labstack/echo/Gopkg.toml delete mode 100644 vendor/github.com/labstack/echo/LICENSE delete mode 100644 vendor/github.com/labstack/echo/Makefile delete mode 100644 vendor/github.com/labstack/echo/README.md delete mode 100644 vendor/github.com/labstack/echo/bind.go delete mode 100644 vendor/github.com/labstack/echo/context.go delete mode 100644 vendor/github.com/labstack/echo/echo.go delete mode 100644 vendor/github.com/labstack/echo/group.go delete mode 100644 vendor/github.com/labstack/echo/log.go delete mode 100644 vendor/github.com/labstack/echo/middleware/basic_auth.go delete mode 100644 vendor/github.com/labstack/echo/middleware/body_dump.go delete mode 100644 vendor/github.com/labstack/echo/middleware/body_limit.go delete mode 100644 vendor/github.com/labstack/echo/middleware/compress.go delete mode 100644 vendor/github.com/labstack/echo/middleware/cors.go delete mode 100644 vendor/github.com/labstack/echo/middleware/csrf.go delete mode 100644 vendor/github.com/labstack/echo/middleware/jwt.go delete mode 100644 vendor/github.com/labstack/echo/middleware/key_auth.go delete mode 100644 vendor/github.com/labstack/echo/middleware/logger.go delete mode 100644 vendor/github.com/labstack/echo/middleware/method_override.go delete mode 100644 vendor/github.com/labstack/echo/middleware/middleware.go delete mode 100644 vendor/github.com/labstack/echo/middleware/proxy.go delete mode 100644 vendor/github.com/labstack/echo/middleware/recover.go delete mode 100644 vendor/github.com/labstack/echo/middleware/redirect.go delete mode 100644 vendor/github.com/labstack/echo/middleware/request_id.go delete mode 100644 vendor/github.com/labstack/echo/middleware/rewrite.go delete mode 100644 vendor/github.com/labstack/echo/middleware/secure.go delete mode 100644 vendor/github.com/labstack/echo/middleware/slash.go delete mode 100644 vendor/github.com/labstack/echo/middleware/static.go delete mode 100644 vendor/github.com/labstack/echo/response.go delete mode 100644 vendor/github.com/labstack/echo/router.go create mode 100644 vendor/github.com/labstack/echo/v4/.editorconfig create mode 100644 vendor/github.com/labstack/echo/v4/.gitattributes create mode 100644 vendor/github.com/labstack/echo/v4/.gitignore create mode 100644 vendor/github.com/labstack/echo/v4/.travis.yml create mode 100644 vendor/github.com/labstack/echo/v4/LICENSE create mode 100644 vendor/github.com/labstack/echo/v4/Makefile create mode 100644 vendor/github.com/labstack/echo/v4/README.md create mode 100644 vendor/github.com/labstack/echo/v4/bind.go create mode 100644 vendor/github.com/labstack/echo/v4/context.go create mode 100644 vendor/github.com/labstack/echo/v4/echo.go create mode 100644 vendor/github.com/labstack/echo/v4/go.mod create mode 100644 vendor/github.com/labstack/echo/v4/go.sum create mode 100644 vendor/github.com/labstack/echo/v4/group.go create mode 100644 vendor/github.com/labstack/echo/v4/log.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/basic_auth.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/body_dump.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/body_limit.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/compress.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/cors.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/csrf.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/jwt.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/key_auth.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/logger.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/method_override.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/middleware.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/proxy.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/proxy_1_11_n.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/recover.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/redirect.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/request_id.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/rewrite.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/secure.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/slash.go create mode 100644 vendor/github.com/labstack/echo/v4/middleware/static.go create mode 100644 vendor/github.com/labstack/echo/v4/response.go create mode 100644 vendor/github.com/labstack/echo/v4/router.go create mode 100644 vendor/github.com/mattn/go-colorable/colorable_appengine.go create mode 100644 vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go create mode 100644 vendor/github.com/nlopes/slack/.gometalinter.json create mode 100644 vendor/github.com/nlopes/slack/reminders.go create mode 100644 vendor/github.com/shazow/ssh-chat/internal/sanitize/sanitize.go create mode 100644 vendor/github.com/sirupsen/logrus/terminal_check_aix.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_aix.go create mode 100644 vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s create mode 100644 vendor/golang.org/x/sys/unix/fcntl_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/mkasm_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/mksyscall.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall.pl create mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.pl create mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.pl create mode 100644 vendor/golang.org/x/sys/unix/mksysnum.go delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum_darwin.pl delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_11.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_11.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_arm64.go diff --git a/bridge/api/api.go b/bridge/api/api.go index f8a7c04c..9a3f1178 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -8,8 +8,8 @@ import ( "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge/config" - "github.com/labstack/echo" - "github.com/labstack/echo/middleware" + "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" "github.com/zfjagann/golang-ring" ) @@ -117,20 +117,14 @@ func (b *API) handleStream(c echo.Context) error { return err } c.Response().Flush() - closeNotifier := c.Response().CloseNotify() for { - select { - case <-closeNotifier: - return nil - default: - msg := b.Messages.Dequeue() - if msg != nil { - if err := json.NewEncoder(c.Response()).Encode(msg); err != nil { - return err - } - c.Response().Flush() + msg := b.Messages.Dequeue() + if msg != nil { + if err := json.NewEncoder(c.Response()).Encode(msg); err != nil { + return err } - time.Sleep(200 * time.Millisecond) + c.Response().Flush() } + time.Sleep(200 * time.Millisecond) } } diff --git a/go.mod b/go.mod index 85006d47..1f8cb17f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/Philipp15b/go-steam v1.0.1-0.20180818081528-681bd9573329 github.com/bwmarrin/discordgo v0.19.0 github.com/dfordsoft/golib v0.0.0-20180902042739-76ee6ab99bec - github.com/dgrijalva/jwt-go v0.0.0-20170508165458-6c8dedd55f8a // indirect github.com/fsnotify/fsnotify v1.4.7 github.com/go-telegram-bot-api/telegram-bot-api v4.6.5-0.20181225215658-ec221ba9ea45+incompatible github.com/golang/protobuf v0.0.0-20170613224224-e325f446bebc // indirect @@ -18,10 +17,9 @@ require ( github.com/hpcloud/tail v1.0.0 // indirect github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 github.com/jtolds/gls v4.2.1+incompatible // indirect - github.com/kardianos/osext v0.0.0-20170207191655-9b883c5eb462 // indirect + github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect github.com/kr/pretty v0.1.0 // indirect - github.com/labstack/echo v3.3.5+incompatible - github.com/labstack/gommon v0.2.1 // indirect + github.com/labstack/echo/v4 v4.0.0 github.com/lrstanley/girc v0.0.0-20190102153329-c1e59a02f488 github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 // indirect github.com/lusis/slack-test v0.0.0-20180109053238-3c758769bfa6 // indirect @@ -30,37 +28,30 @@ require ( github.com/matterbridge/gozulipbot v0.0.0-20180507190239-b6bb12d33544 github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 github.com/mattermost/mattermost-server v5.5.0+incompatible - github.com/mattn/go-colorable v0.0.0-20170210172801-5411d3eea597 // indirect - github.com/mattn/go-isatty v0.0.0-20170216235908-dda3de49cbfc // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect - github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474 // indirect github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff // indirect github.com/nicksnyder/go-i18n v1.4.0 // indirect - github.com/nlopes/slack v0.4.1-0.20181111125009-5963eafd777b + github.com/nlopes/slack v0.5.0 github.com/onsi/ginkgo v1.6.0 // indirect github.com/onsi/gomega v1.4.1 // indirect github.com/paulrosania/go-charset v0.0.0-20151028000031-621bb39fcc83 github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606 // indirect - github.com/peterhellberg/emojilib v0.0.0-20180820090156-eeb3823dab9a + github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320 github.com/pkg/errors v0.8.0 // indirect github.com/rs/xid v1.2.1 github.com/russross/blackfriday v2.0.0+incompatible github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca - github.com/shazow/ssh-chat v0.0.0-20181028152505-f36d7eb9ccc6 + github.com/shazow/ssh-chat v0.0.0-20190125184227-81d7e1686296 github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect - github.com/sirupsen/logrus v1.2.0 + github.com/sirupsen/logrus v1.3.0 github.com/smartystreets/assertions v0.0.0-20180803164922-886ec427f6b9 // indirect github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect - github.com/spf13/cast v1.3.0 // indirect - github.com/spf13/pflag v1.0.3 // indirect - github.com/spf13/viper v1.2.1 - github.com/stretchr/testify v1.2.2 + github.com/spf13/viper v1.3.1 + github.com/stretchr/testify v1.3.0 github.com/technoweenie/multipartstreamer v1.0.1 // indirect - github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a // indirect - github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect - github.com/zfjagann/golang-ring v0.0.0-20141111230621-17637388c9f6 + github.com/zfjagann/golang-ring v0.0.0-20190106091943-a88bb6aef447 gitlab.com/golang-commonmark/html v0.0.0-20180917080848-cfaf75183c4a // indirect gitlab.com/golang-commonmark/linkify v0.0.0-20180917065525-c22b7bdb1179 // indirect gitlab.com/golang-commonmark/markdown v0.0.0-20181102083822-772775880e1f @@ -70,10 +61,8 @@ require ( go.uber.org/atomic v1.3.2 // indirect go.uber.org/multierr v1.1.0 // indirect go.uber.org/zap v1.9.1 // indirect - golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 // indirect golang.org/x/net v0.0.0-20180108090419-434ec0c7fe37 // indirect golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect - golang.org/x/sys v0.0.0-20181116161606-93218def8b18 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index 7cc22f1b..c5aca265 100644 --- a/go.sum +++ b/go.sum @@ -6,14 +6,19 @@ github.com/Philipp15b/go-steam v1.0.1-0.20180818081528-681bd9573329 h1:xZBoq249G github.com/Philipp15b/go-steam v1.0.1-0.20180818081528-681bd9573329/go.mod h1:HuVM+sZFzumUdKPWiz+IlCMb4RdsKdT3T+nQBKL+sYg= github.com/alexcesaro/log v0.0.0-20150915221235-61e686294e58 h1:MkpmYfld/S8kXqTYI68DfL8/hHXjHogL120Dy00TIxc= github.com/alexcesaro/log v0.0.0-20150915221235-61e686294e58/go.mod h1:YNfsMyWSs+h+PaYkxGeMVmVCX75Zj/pqdjbu12ciCYE= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/bwmarrin/discordgo v0.19.0 h1:kMED/DB0NR1QhRcalb85w0Cu3Ep2OrGAqZH1R5awQiY= github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dfordsoft/golib v0.0.0-20180902042739-76ee6ab99bec h1:JEUiu7P9smN7zgX87a2zVnnbPPickIM9Gf9OIhsIgWQ= github.com/dfordsoft/golib v0.0.0-20180902042739-76ee6ab99bec/go.mod h1:UGa5M2Sz/Uh13AMse4+RELKCDw7kqgqlTjeGae+7vUY= -github.com/dgrijalva/jwt-go v0.0.0-20170508165458-6c8dedd55f8a h1:MuHMeSsXbNEeUyxjB7T9P8s1+5k8OLTC/M27qsVwixM= -github.com/dgrijalva/jwt-go v0.0.0-20170508165458-6c8dedd55f8a/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-telegram-bot-api/telegram-bot-api v4.6.5-0.20181225215658-ec221ba9ea45+incompatible h1:i64CCJcSqkRIkm5OSdZQjZq84/gJsk2zNwHWIRYWlKE= @@ -40,8 +45,8 @@ github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7 h1:K//n/AqR5HjG3q github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/kardianos/osext v0.0.0-20170207191655-9b883c5eb462 h1:oSOOTPHkCzMeu1vJ0nHxg5+XZBdMMjNa+6NPnm8arok= -github.com/kardianos/osext v0.0.0-20170207191655-9b883c5eb462/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= +github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 h1:PJPDf8OUfOK1bb/NeTKd4f1QXZItOX389VN3B6qC8ro= +github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -49,10 +54,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/labstack/echo v3.3.5+incompatible h1:9PfxPUmasKzeJor9uQTaXLT6WUG/r+vSTmvXxvv3JO4= -github.com/labstack/echo v3.3.5+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= -github.com/labstack/gommon v0.2.1 h1:C+I4NYknueQncqKYZQ34kHsLZJVeB5KwPUhnO0nmbpU= -github.com/labstack/gommon v0.2.1/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= +github.com/labstack/echo/v4 v4.0.0 h1:q1GH+caIXPP7H2StPIdzy/ez9CO0EepqYeUg6vi9SWM= +github.com/labstack/echo/v4 v4.0.0/go.mod h1:tZv7nai5buKSg5h/8E6zz4LsD/Dqh9/91Mvs7Z5Zyno= +github.com/labstack/gommon v0.2.8 h1:JvRqmeZcfrHC5u6uVleB4NxxNbzx6gpbJiQknDbKQu0= +github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= github.com/lrstanley/girc v0.0.0-20190102153329-c1e59a02f488 h1:dDEQN5oaa0WOzEiPDSbOugW/e2I/SWY98HYRdcwmGfY= github.com/lrstanley/girc v0.0.0-20190102153329-c1e59a02f488/go.mod h1:7cRs1SIBfKQ7e3Tam6GKTILSNHzR862JD0JpINaZoJk= github.com/lusis/go-slackbot v0.0.0-20180109053408-401027ccfef5 h1:AsEBgzv3DhuYHI/GiQh2HxvTP71HCCE9E/tzGUzGdtU= @@ -71,13 +76,12 @@ github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749 github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61/go.mod h1:iXGEotOvwI1R1SjLxRc+BF5rUORTMtE0iMZBT2lxqAU= github.com/mattermost/mattermost-server v5.5.0+incompatible h1:0wcLGgYtd+YImtLDPf2AOfpBHxbU4suATx+6XKw1XbU= github.com/mattermost/mattermost-server v5.5.0+incompatible/go.mod h1:5L6MjAec+XXQwMIt791Ganu45GKsSiM+I0tLR9wUj8Y= -github.com/mattn/go-colorable v0.0.0-20170210172801-5411d3eea597 h1:hGizH4aMDFFt1iOA4HNKC13lqIBoCyxIjWcAnWIy7aU= -github.com/mattn/go-colorable v0.0.0-20170210172801-5411d3eea597/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-isatty v0.0.0-20170216235908-dda3de49cbfc h1:pK7tzC30erKOTfEDCYGvPZQCkmM9X5iSmmAR5m9x3Yc= -github.com/mattn/go-isatty v0.0.0-20170216235908-dda3de49cbfc/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474 h1:oKIteTqeSpenyTrOVj5zkiyCaflLa8B+CD0324otT+o= @@ -86,8 +90,8 @@ github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff h1:HLGD5/9UxxfEuO9Dt github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff/go.mod h1:B8jLfIIPn2sKyWr0D7cL2v7tnrDD5z291s2Zypdu89E= github.com/nicksnyder/go-i18n v1.4.0 h1:AgLl+Yq7kg5OYlzCgu9cKTZOyI4tD/NgukKqLqC8E+I= github.com/nicksnyder/go-i18n v1.4.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= -github.com/nlopes/slack v0.4.1-0.20181111125009-5963eafd777b h1:8ncrr7Xps0GafXIxBzrq1qSjy1zhiCDp/9C4cOrE+GU= -github.com/nlopes/slack v0.4.1-0.20181111125009-5963eafd777b/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM= +github.com/nlopes/slack v0.5.0 h1:NbIae8Kd0NpqaEI3iUrsuS0KbcEDhzhc939jLW5fNm0= +github.com/nlopes/slack v0.5.0/go.mod h1:jVI4BBK3lSktibKahxBF74txcK2vyvkza1z/+rRnVAM= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U= @@ -98,8 +102,8 @@ github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606 h1:/CPgDYrfeK2LMK6xcU github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/peterhellberg/emojilib v0.0.0-20180820090156-eeb3823dab9a h1:zAss6STq7oejKWTMEUYDUKYZhqXe0xALo8pJhJ3JJAs= -github.com/peterhellberg/emojilib v0.0.0-20180820090156-eeb3823dab9a/go.mod h1:G7LufuPajuIvdt9OitkNt2qh0mmvD4bfRgRM7bhDIOA= +github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320 h1:YxcQy/DV+48NGv1lxx1vsWBzs6W1f1ogubkuCozxpX0= +github.com/peterhellberg/emojilib v0.0.0-20190124112554-c18758d55320/go.mod h1:G7LufuPajuIvdt9OitkNt2qh0mmvD4bfRgRM7bhDIOA= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -112,43 +116,45 @@ github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxT github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/shazow/rateio v0.0.0-20150116013248-e8e00881e5c1 h1:Lx3BlDGFElJt4u/zKc9A3BuGYbQAGlEFyPuUA3jeMD0= github.com/shazow/rateio v0.0.0-20150116013248-e8e00881e5c1/go.mod h1:vt2jWY/3Qw1bIzle5thrJWucsLuuX9iUNnp20CqCciI= -github.com/shazow/ssh-chat v0.0.0-20181028152505-f36d7eb9ccc6 h1:qNoZx1RWPGKiqfs8ZZAYsYtw3ejo3HIF7iECaeaJhFk= -github.com/shazow/ssh-chat v0.0.0-20181028152505-f36d7eb9ccc6/go.mod h1:SA/9+Wy3zV0UvPjttpGgs90FS9ZZ5D/LTffnVqdIBE8= +github.com/shazow/ssh-chat v0.0.0-20190125184227-81d7e1686296 h1:8RLq547MSVc6vhOuCl4Ca0TsAQknj6NX6ZLSZ3+xmio= +github.com/shazow/ssh-chat v0.0.0-20190125184227-81d7e1686296/go.mod h1:1GLXsL4esywkpNId3v4QWuMf3THtWGitWvtQ/L3aSA4= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= +github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180803164922-886ec427f6b9 h1:lXQ+j+KwZcbwrbgU0Rp4Eglg3EJLHbuZU3BbOqAGBmg= github.com/smartystreets/assertions v0.0.0-20180803164922-886ec427f6b9/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.2.0 h1:HHl1DSRbEQN2i8tJmtS6ViPyHx35+p51amrdsiTCrkg= -github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.2.1 h1:bIcUwXqLseLF3BDAZduuNfekWG87ibtFxi59Bq+oI9M= -github.com/spf13/viper v1.2.1/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI= +github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= +github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= -github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a h1:AOcehBWpFhYPYw0ioDTppQzgI8pAAahVCiMSKTp9rbo= -github.com/valyala/bytebufferpool v0.0.0-20160817181652-e746df99fe4a/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QINDnvyZuTaACm9ofY+PRh+5vFz4oxBZeF8= github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= -github.com/zfjagann/golang-ring v0.0.0-20141111230621-17637388c9f6 h1:/WULP+6asFz569UbOwg87f3iDT7T+GF5/vjLmL51Pdk= -github.com/zfjagann/golang-ring v0.0.0-20141111230621-17637388c9f6/go.mod h1:0MsIttMJIF/8Y7x0XjonJP7K99t3sR6bjj4m5S4JmqU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/zfjagann/golang-ring v0.0.0-20190106091943-a88bb6aef447 h1:CHgPZh8bFkZmislPrr/0gd7MciDAX+JJB70A2/5Lvmo= +github.com/zfjagann/golang-ring v0.0.0-20190106091943-a88bb6aef447/go.mod h1:0MsIttMJIF/8Y7x0XjonJP7K99t3sR6bjj4m5S4JmqU= gitlab.com/golang-commonmark/html v0.0.0-20180917080848-cfaf75183c4a h1:Ax7kdHNICZiIeFpmevmaEWb0Ae3BUj3zCTKhZHZ+zd0= gitlab.com/golang-commonmark/html v0.0.0-20180917080848-cfaf75183c4a/go.mod h1:JT4uoTz0tfPoyVH88GZoWDNm5NHJI2VbUW+eyPClueI= gitlab.com/golang-commonmark/linkify v0.0.0-20180917065525-c22b7bdb1179 h1:rbON2KwBnWuFMlSHM8LELLlwroDRZw6xv0e6il6e5dk= @@ -167,21 +173,20 @@ go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/crypto v0.0.0-20180119074636-ee41a25c63fb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 h1:y6ce7gCWtnH+m3dCjzQ1PCuwl28DDIc3VNnvY29DlIA= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869 h1:kkXA53yGe04D0adEYJwEVQjeBppL01Exg+fnMjfUraU= -golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664 h1:YbZJ76lQ1BqNhVe7dKTSB67wDrc2VPRR75IyGyyPDX8= +golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/net v0.0.0-20180108090419-434ec0c7fe37 h1:BkNcmLtAVeWe9h5k0jt24CQgaG5vb4x/doFbAiEC/Ho= golang.org/x/net v0.0.0-20180108090419-434ec0c7fe37/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180117170059-2c42eef0765b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116161606-93218def8b18 h1:Wh+XCfg3kNpjhdq2LXrsiOProjtQZKme5XUx7VcxwAw= -golang.org/x/sys v0.0.0-20181116161606-93218def8b18/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ= +golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -193,5 +198,5 @@ gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXL gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/dgrijalva/jwt-go/README.md b/vendor/github.com/dgrijalva/jwt-go/README.md index 70bae69e..d358d881 100644 --- a/vendor/github.com/dgrijalva/jwt-go/README.md +++ b/vendor/github.com/dgrijalva/jwt-go/README.md @@ -1,11 +1,15 @@ -A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) +# jwt-go [![Build Status](https://travis-ci.org/dgrijalva/jwt-go.svg?branch=master)](https://travis-ci.org/dgrijalva/jwt-go) +[![GoDoc](https://godoc.org/github.com/dgrijalva/jwt-go?status.svg)](https://godoc.org/github.com/dgrijalva/jwt-go) + +A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) -**BREAKING CHANGES:*** Version 3.0.0 is here. It includes _a lot_ of changes including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code. +**NEW VERSION COMING:** There have been a lot of improvements suggested since the version 3.0.0 released in 2016. I'm working now on cutting two different releases: 3.2.0 will contain any non-breaking changes or enhancements. 4.0.0 will follow shortly which will include breaking changes. See the 4.0.0 milestone to get an idea of what's coming. If you have other ideas, or would like to participate in 4.0.0, now's the time. If you depend on this library and don't want to be interrupted, I recommend you use your dependency mangement tool to pin to version 3. -**NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided. +**SECURITY NOTICE:** Some older versions of Go have a security issue in the cryotp/elliptic. Recommendation is to upgrade to at least 1.8.3. See issue #216 for more detail. +**SECURITY NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided. ## What the heck is a JWT? @@ -37,7 +41,7 @@ Here's an example of an extension that integrates with the Google App Engine sig ## Compliance -This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences: +This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences: * In order to protect against accidental use of [Unsecured JWTs](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#UnsecuredJWT), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key. @@ -47,7 +51,10 @@ This library is considered production ready. Feedback and feature requests are This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `master`. Periodically, versions will be tagged from `master`. You can find all the releases on [the project releases page](https://github.com/dgrijalva/jwt-go/releases). -While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v2`. It will do the right thing WRT semantic versioning. +While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v3`. It will do the right thing WRT semantic versioning. + +**BREAKING CHANGES:*** +* Version 3.0.0 includes _a lot_ of changes from the 2.x line, including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code. ## Usage Tips @@ -68,18 +75,26 @@ Symmetric signing methods, such as HSA, use only a single secret. This is probab Asymmetric signing methods, such as RSA, use different keys for signing and verifying tokens. This makes it possible to produce tokens with a private key, and allow any consumer to access the public key for verification. +### Signing Methods and Key Types + +Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones: + +* The [HMAC signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation +* The [RSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation +* The [ECDSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation + ### JWT and OAuth It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication. Without going too far down the rabbit hole, here's a description of the interaction of these technologies: -* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth. +* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth. * OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token. * Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL. - + ## More Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go). -The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in to documentation. +The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation. diff --git a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md index b605b450..63702983 100644 --- a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md +++ b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md @@ -1,5 +1,18 @@ ## `jwt-go` Version History +#### 3.2.0 + +* Added method `ParseUnverified` to allow users to split up the tasks of parsing and validation +* HMAC signing method returns `ErrInvalidKeyType` instead of `ErrInvalidKey` where appropriate +* Added options to `request.ParseFromRequest`, which allows for an arbitrary list of modifiers to parsing behavior. Initial set include `WithClaims` and `WithParser`. Existing usage of this function will continue to work as before. +* Deprecated `ParseFromRequestWithClaims` to simplify API in the future. + +#### 3.1.0 + +* Improvements to `jwt` command line tool +* Added `SkipClaimsValidation` option to `Parser` +* Documentation updates + #### 3.0.0 * **Compatibility Breaking Changes**: See MIGRATION_GUIDE.md for tips on updating your code diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go index 2f59a222..f9773812 100644 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go @@ -14,6 +14,7 @@ var ( ) // Implements the ECDSA family of signing methods signing methods +// Expects *ecdsa.PrivateKey for signing and *ecdsa.PublicKey for verification type SigningMethodECDSA struct { Name string Hash crypto.Hash diff --git a/vendor/github.com/dgrijalva/jwt-go/hmac.go b/vendor/github.com/dgrijalva/jwt-go/hmac.go index c2299192..addbe5d4 100644 --- a/vendor/github.com/dgrijalva/jwt-go/hmac.go +++ b/vendor/github.com/dgrijalva/jwt-go/hmac.go @@ -7,6 +7,7 @@ import ( ) // Implements the HMAC-SHA family of signing methods signing methods +// Expects key type of []byte for both signing and validation type SigningMethodHMAC struct { Name string Hash crypto.Hash @@ -90,5 +91,5 @@ func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, return EncodeSegment(hasher.Sum(nil)), nil } - return "", ErrInvalidKey + return "", ErrInvalidKeyType } diff --git a/vendor/github.com/dgrijalva/jwt-go/parser.go b/vendor/github.com/dgrijalva/jwt-go/parser.go index 7bf1c4ea..d6901d9a 100644 --- a/vendor/github.com/dgrijalva/jwt-go/parser.go +++ b/vendor/github.com/dgrijalva/jwt-go/parser.go @@ -21,55 +21,9 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { } func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) { - parts := strings.Split(tokenString, ".") - if len(parts) != 3 { - return nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) - } - - var err error - token := &Token{Raw: tokenString} - - // parse Header - var headerBytes []byte - if headerBytes, err = DecodeSegment(parts[0]); err != nil { - if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") { - return token, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed) - } - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - if err = json.Unmarshal(headerBytes, &token.Header); err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // parse Claims - var claimBytes []byte - token.Claims = claims - - if claimBytes, err = DecodeSegment(parts[1]); err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) - if p.UseJSONNumber { - dec.UseNumber() - } - // JSON Decode. Special case for map type to avoid weird pointer behavior - if c, ok := token.Claims.(MapClaims); ok { - err = dec.Decode(&c) - } else { - err = dec.Decode(&claims) - } - // Handle decode error + token, parts, err := p.ParseUnverified(tokenString, claims) if err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // Lookup signature method - if method, ok := token.Header["alg"].(string); ok { - if token.Method = GetSigningMethod(method); token.Method == nil { - return token, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable) - } - } else { - return token, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable) + return token, err } // Verify signing method is in the required set @@ -96,6 +50,9 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf } if key, err = keyFunc(token); err != nil { // keyFunc returned an error + if ve, ok := err.(*ValidationError); ok { + return token, ve + } return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable} } @@ -129,3 +86,63 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf return token, vErr } + +// WARNING: Don't use this method unless you know what you're doing +// +// This method parses the token but doesn't validate the signature. It's only +// ever useful in cases where you know the signature is valid (because it has +// been checked previously in the stack) and you want to extract values from +// it. +func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) { + parts = strings.Split(tokenString, ".") + if len(parts) != 3 { + return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) + } + + token = &Token{Raw: tokenString} + + // parse Header + var headerBytes []byte + if headerBytes, err = DecodeSegment(parts[0]); err != nil { + if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") { + return token, parts, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed) + } + return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} + } + if err = json.Unmarshal(headerBytes, &token.Header); err != nil { + return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} + } + + // parse Claims + var claimBytes []byte + token.Claims = claims + + if claimBytes, err = DecodeSegment(parts[1]); err != nil { + return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} + } + dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) + if p.UseJSONNumber { + dec.UseNumber() + } + // JSON Decode. Special case for map type to avoid weird pointer behavior + if c, ok := token.Claims.(MapClaims); ok { + err = dec.Decode(&c) + } else { + err = dec.Decode(&claims) + } + // Handle decode error + if err != nil { + return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} + } + + // Lookup signature method + if method, ok := token.Header["alg"].(string); ok { + if token.Method = GetSigningMethod(method); token.Method == nil { + return token, parts, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable) + } + } else { + return token, parts, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable) + } + + return token, parts, nil +} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa.go b/vendor/github.com/dgrijalva/jwt-go/rsa.go index 0ae0b198..e4caf1ca 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa.go @@ -7,6 +7,7 @@ import ( ) // Implements the RSA family of signing methods signing methods +// Expects *rsa.PrivateKey for signing and *rsa.PublicKey for validation type SigningMethodRSA struct { Name string Hash crypto.Hash @@ -44,7 +45,7 @@ func (m *SigningMethodRSA) Alg() string { } // Implements the Verify method from SigningMethod -// For this signing method, must be an rsa.PublicKey structure. +// For this signing method, must be an *rsa.PublicKey structure. func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error { var err error @@ -73,7 +74,7 @@ func (m *SigningMethodRSA) Verify(signingString, signature string, key interface } // Implements the Sign method from SigningMethod -// For this signing method, must be an rsa.PrivateKey structure. +// For this signing method, must be an *rsa.PrivateKey structure. func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) { var rsaKey *rsa.PrivateKey var ok bool diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go index 213a90db..a5ababf9 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go @@ -39,6 +39,38 @@ func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { return pkey, nil } +// Parse PEM encoded PKCS1 or PKCS8 private key protected with password +func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error) { + var err error + + // Parse PEM block + var block *pem.Block + if block, _ = pem.Decode(key); block == nil { + return nil, ErrKeyMustBePEMEncoded + } + + var parsedKey interface{} + + var blockDecrypted []byte + if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil { + return nil, err + } + + if parsedKey, err = x509.ParsePKCS1PrivateKey(blockDecrypted); err != nil { + if parsedKey, err = x509.ParsePKCS8PrivateKey(blockDecrypted); err != nil { + return nil, err + } + } + + var pkey *rsa.PrivateKey + var ok bool + if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok { + return nil, ErrNotRSAPrivateKey + } + + return pkey, nil +} + // Parse PEM encoded PKCS1 or PKCS8 public key func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { var err error diff --git a/vendor/github.com/kardianos/osext/osext_go18.go b/vendor/github.com/kardianos/osext/osext_go18.go index 7065a5ff..009d8a92 100644 --- a/vendor/github.com/kardianos/osext/osext_go18.go +++ b/vendor/github.com/kardianos/osext/osext_go18.go @@ -1,4 +1,4 @@ -//+build go1.8 +//+build go1.8,!openbsd package osext diff --git a/vendor/github.com/kardianos/osext/osext_procfs.go b/vendor/github.com/kardianos/osext/osext_procfs.go index 7b0debbb..e1f16f88 100644 --- a/vendor/github.com/kardianos/osext/osext_procfs.go +++ b/vendor/github.com/kardianos/osext/osext_procfs.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !go1.8,linux !go1.8,netbsd !go1.8,solaris !go1.8,dragonfly +// +build !go1.8,android !go1.8,linux !go1.8,netbsd !go1.8,solaris !go1.8,dragonfly package osext @@ -16,7 +16,7 @@ import ( func executable() (string, error) { switch runtime.GOOS { - case "linux": + case "linux", "android": const deletedTag = " (deleted)" execpath, err := os.Readlink("/proc/self/exe") if err != nil { diff --git a/vendor/github.com/kardianos/osext/osext_sysctl.go b/vendor/github.com/kardianos/osext/osext_sysctl.go index 579f224a..33cee252 100644 --- a/vendor/github.com/kardianos/osext/osext_sysctl.go +++ b/vendor/github.com/kardianos/osext/osext_sysctl.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !go1.8,darwin !go1.8,freebsd !go1.8,openbsd +// +build !go1.8,darwin !go1.8,freebsd openbsd package osext diff --git a/vendor/github.com/labstack/echo/.editorconfig b/vendor/github.com/labstack/echo/.editorconfig deleted file mode 100644 index 17ae50dd..00000000 --- a/vendor/github.com/labstack/echo/.editorconfig +++ /dev/null @@ -1,25 +0,0 @@ -# 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/vendor/github.com/labstack/echo/.gitattributes b/vendor/github.com/labstack/echo/.gitattributes deleted file mode 100644 index 49b63e52..00000000 --- a/vendor/github.com/labstack/echo/.gitattributes +++ /dev/null @@ -1,20 +0,0 @@ -# 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/vendor/github.com/labstack/echo/.gitignore b/vendor/github.com/labstack/echo/.gitignore deleted file mode 100644 index dd74acca..00000000 --- a/vendor/github.com/labstack/echo/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -coverage.txt -_test -vendor -.idea -*.iml -*.out diff --git a/vendor/github.com/labstack/echo/.travis.yml b/vendor/github.com/labstack/echo/.travis.yml deleted file mode 100644 index 05e53b16..00000000 --- a/vendor/github.com/labstack/echo/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -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/vendor/github.com/labstack/echo/Gopkg.lock b/vendor/github.com/labstack/echo/Gopkg.lock deleted file mode 100644 index f3c3b8d2..00000000 --- a/vendor/github.com/labstack/echo/Gopkg.lock +++ /dev/null @@ -1,75 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - name = "github.com/dgrijalva/jwt-go" - packages = ["."] - revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" - version = "v3.2.0" - -[[projects]] - name = "github.com/labstack/gommon" - packages = ["bytes","color","log","random"] - revision = "6fe1405d73ec4bd4cd8a4ac8e2a2b2bf95d03954" - version = "0.2.4" - -[[projects]] - name = "github.com/mattn/go-colorable" - packages = ["."] - revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" - version = "v0.0.9" - -[[projects]] - name = "github.com/mattn/go-isatty" - packages = ["."] - revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" - version = "v0.0.3" - -[[projects]] - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - name = "github.com/stretchr/testify" - packages = ["assert"] - revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" - version = "v1.2.1" - -[[projects]] - branch = "master" - name = "github.com/valyala/bytebufferpool" - packages = ["."] - revision = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7" - -[[projects]] - branch = "master" - name = "github.com/valyala/fasttemplate" - packages = ["."] - revision = "dcecefd839c4193db0d35b88ec65b4c12d360ab0" - -[[projects]] - branch = "master" - name = "golang.org/x/crypto" - packages = ["acme","acme/autocert"] - revision = "182114d582623c1caa54f73de9c7224e23a48487" - -[[projects]] - branch = "master" - name = "golang.org/x/sys" - packages = ["unix"] - revision = "c28acc882ebcbfbe8ce9f0f14b9ac26ee138dd51" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "9c7b45e80fe353405800cf01f429b3a203cfb8d4468a04c64a908e11a98ea764" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/github.com/labstack/echo/Gopkg.toml b/vendor/github.com/labstack/echo/Gopkg.toml deleted file mode 100644 index 61de60cb..00000000 --- a/vendor/github.com/labstack/echo/Gopkg.toml +++ /dev/null @@ -1,42 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - name = "github.com/dgrijalva/jwt-go" - version = "3.2.0" - -[[constraint]] - name = "github.com/labstack/gommon" - version = "0.2.4" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.2.1" - -[[constraint]] - branch = "master" - name = "github.com/valyala/fasttemplate" - -[[constraint]] - branch = "master" - name = "golang.org/x/crypto" \ No newline at end of file diff --git a/vendor/github.com/labstack/echo/LICENSE b/vendor/github.com/labstack/echo/LICENSE deleted file mode 100644 index b5b006b4..00000000 --- a/vendor/github.com/labstack/echo/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/vendor/github.com/labstack/echo/Makefile b/vendor/github.com/labstack/echo/Makefile deleted file mode 100644 index 494667d8..00000000 --- a/vendor/github.com/labstack/echo/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -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/vendor/github.com/labstack/echo/README.md b/vendor/github.com/labstack/echo/README.md deleted file mode 100644 index 0f609df4..00000000 --- a/vendor/github.com/labstack/echo/README.md +++ /dev/null @@ -1,99 +0,0 @@ - - -[![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
-Source: https://github.com/vishr/web-framework-benchmark
-Lower is better! - - - -## [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/vendor/github.com/labstack/echo/bind.go b/vendor/github.com/labstack/echo/bind.go deleted file mode 100644 index 38e07150..00000000 --- a/vendor/github.com/labstack/echo/bind.go +++ /dev/null @@ -1,261 +0,0 @@ -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/vendor/github.com/labstack/echo/context.go b/vendor/github.com/labstack/echo/context.go deleted file mode 100644 index cf780c51..00000000 --- a/vendor/github.com/labstack/echo/context.go +++ /dev/null @@ -1,576 +0,0 @@ -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/vendor/github.com/labstack/echo/echo.go b/vendor/github.com/labstack/echo/echo.go deleted file mode 100644 index 41ac6b5e..00000000 --- a/vendor/github.com/labstack/echo/echo.go +++ /dev/null @@ -1,781 +0,0 @@ -/* -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/vendor/github.com/labstack/echo/group.go b/vendor/github.com/labstack/echo/group.go deleted file mode 100644 index 5257e83c..00000000 --- a/vendor/github.com/labstack/echo/group.go +++ /dev/null @@ -1,120 +0,0 @@ -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/vendor/github.com/labstack/echo/log.go b/vendor/github.com/labstack/echo/log.go deleted file mode 100644 index b194c39c..00000000 --- a/vendor/github.com/labstack/echo/log.go +++ /dev/null @@ -1,40 +0,0 @@ -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/vendor/github.com/labstack/echo/middleware/basic_auth.go b/vendor/github.com/labstack/echo/middleware/basic_auth.go deleted file mode 100644 index e6c96324..00000000 --- a/vendor/github.com/labstack/echo/middleware/basic_auth.go +++ /dev/null @@ -1,106 +0,0 @@ -package middleware - -import ( - "encoding/base64" - "strconv" - "strings" - - "github.com/labstack/echo" -) - -type ( - // BasicAuthConfig defines the config for BasicAuth middleware. - BasicAuthConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Validator is a function to validate BasicAuth credentials. - // Required. - Validator BasicAuthValidator - - // Realm is a string to define realm attribute of BasicAuth. - // Default value "Restricted". - Realm string - } - - // BasicAuthValidator defines a function to validate BasicAuth credentials. - BasicAuthValidator func(string, string, echo.Context) (bool, error) -) - -const ( - basic = "basic" - defaultRealm = "Restricted" -) - -var ( - // DefaultBasicAuthConfig is the default BasicAuth middleware config. - DefaultBasicAuthConfig = BasicAuthConfig{ - Skipper: DefaultSkipper, - Realm: defaultRealm, - } -) - -// BasicAuth returns an BasicAuth middleware. -// -// For valid credentials it calls the next handler. -// For missing or invalid credentials, it sends "401 - Unauthorized" response. -func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc { - c := DefaultBasicAuthConfig - c.Validator = fn - return BasicAuthWithConfig(c) -} - -// BasicAuthWithConfig returns an BasicAuth middleware with config. -// See `BasicAuth()`. -func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc { - // Defaults - if config.Validator == nil { - panic("echo: basic-auth middleware requires a validator function") - } - if config.Skipper == nil { - config.Skipper = DefaultBasicAuthConfig.Skipper - } - if config.Realm == "" { - config.Realm = defaultRealm - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - auth := c.Request().Header.Get(echo.HeaderAuthorization) - l := len(basic) - - if len(auth) > l+1 && strings.ToLower(auth[:l]) == basic { - b, err := base64.StdEncoding.DecodeString(auth[l+1:]) - if err != nil { - return err - } - cred := string(b) - for i := 0; i < len(cred); i++ { - if cred[i] == ':' { - // Verify credentials - valid, err := config.Validator(cred[:i], cred[i+1:], c) - if err != nil { - return err - } else if valid { - return next(c) - } - break - } - } - } - - realm := defaultRealm - if config.Realm != defaultRealm { - realm = strconv.Quote(config.Realm) - } - - // Need to return `401` for browsers to pop-up login box. - c.Response().Header().Set(echo.HeaderWWWAuthenticate, basic+" realm="+realm) - return echo.ErrUnauthorized - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/body_dump.go b/vendor/github.com/labstack/echo/middleware/body_dump.go deleted file mode 100644 index e64e5e11..00000000 --- a/vendor/github.com/labstack/echo/middleware/body_dump.go +++ /dev/null @@ -1,111 +0,0 @@ -package middleware - -import ( - "bufio" - "bytes" - "io" - "io/ioutil" - "net" - "net/http" - - "github.com/labstack/echo" -) - -type ( - // BodyDumpConfig defines the config for BodyDump middleware. - BodyDumpConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Handler receives request and response payload. - // Required. - Handler BodyDumpHandler - } - - // BodyDumpHandler receives the request and response payload. - BodyDumpHandler func(echo.Context, []byte, []byte) - - bodyDumpResponseWriter struct { - io.Writer - http.ResponseWriter - } -) - -var ( - // DefaultBodyDumpConfig is the default BodyDump middleware config. - DefaultBodyDumpConfig = BodyDumpConfig{ - Skipper: DefaultSkipper, - } -) - -// BodyDump returns a BodyDump middleware. -// -// BodyLimit middleware captures the request and response payload and calls the -// registered handler. -func BodyDump(handler BodyDumpHandler) echo.MiddlewareFunc { - c := DefaultBodyDumpConfig - c.Handler = handler - return BodyDumpWithConfig(c) -} - -// BodyDumpWithConfig returns a BodyDump middleware with config. -// See: `BodyDump()`. -func BodyDumpWithConfig(config BodyDumpConfig) echo.MiddlewareFunc { - // Defaults - if config.Handler == nil { - panic("echo: body-dump middleware requires a handler function") - } - if config.Skipper == nil { - config.Skipper = DefaultBodyDumpConfig.Skipper - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) (err error) { - if config.Skipper(c) { - return next(c) - } - - // Request - reqBody := []byte{} - if c.Request().Body != nil { // Read - reqBody, _ = ioutil.ReadAll(c.Request().Body) - } - c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(reqBody)) // Reset - - // Response - resBody := new(bytes.Buffer) - mw := io.MultiWriter(c.Response().Writer, resBody) - writer := &bodyDumpResponseWriter{Writer: mw, ResponseWriter: c.Response().Writer} - c.Response().Writer = writer - - if err = next(c); err != nil { - c.Error(err) - } - - // Callback - config.Handler(c, reqBody, resBody.Bytes()) - - return - } - } -} - -func (w *bodyDumpResponseWriter) WriteHeader(code int) { - w.ResponseWriter.WriteHeader(code) -} - -func (w *bodyDumpResponseWriter) Write(b []byte) (int, error) { - return w.Writer.Write(b) -} - -func (w *bodyDumpResponseWriter) Flush() { - w.ResponseWriter.(http.Flusher).Flush() -} - -func (w *bodyDumpResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - return w.ResponseWriter.(http.Hijacker).Hijack() -} - -func (w *bodyDumpResponseWriter) CloseNotify() <-chan bool { - return w.ResponseWriter.(http.CloseNotifier).CloseNotify() -} diff --git a/vendor/github.com/labstack/echo/middleware/body_limit.go b/vendor/github.com/labstack/echo/middleware/body_limit.go deleted file mode 100644 index c83f57e1..00000000 --- a/vendor/github.com/labstack/echo/middleware/body_limit.go +++ /dev/null @@ -1,117 +0,0 @@ -package middleware - -import ( - "fmt" - "io" - "sync" - - "github.com/labstack/echo" - "github.com/labstack/gommon/bytes" -) - -type ( - // BodyLimitConfig defines the config for BodyLimit middleware. - BodyLimitConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Maximum allowed size for a request body, it can be specified - // as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P. - Limit string `yaml:"limit"` - limit int64 - } - - limitedReader struct { - BodyLimitConfig - reader io.ReadCloser - read int64 - context echo.Context - } -) - -var ( - // DefaultBodyLimitConfig is the default BodyLimit middleware config. - DefaultBodyLimitConfig = BodyLimitConfig{ - Skipper: DefaultSkipper, - } -) - -// BodyLimit returns a BodyLimit middleware. -// -// BodyLimit middleware sets the maximum allowed size for a request body, if the -// size exceeds the configured limit, it sends "413 - Request Entity Too Large" -// response. The BodyLimit is determined based on both `Content-Length` request -// header and actual content read, which makes it super secure. -// Limit can be specified as `4x` or `4xB`, where x is one of the multiple from K, M, -// G, T or P. -func BodyLimit(limit string) echo.MiddlewareFunc { - c := DefaultBodyLimitConfig - c.Limit = limit - return BodyLimitWithConfig(c) -} - -// BodyLimitWithConfig returns a BodyLimit middleware with config. -// See: `BodyLimit()`. -func BodyLimitWithConfig(config BodyLimitConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultBodyLimitConfig.Skipper - } - - limit, err := bytes.Parse(config.Limit) - if err != nil { - panic(fmt.Errorf("echo: invalid body-limit=%s", config.Limit)) - } - config.limit = limit - pool := limitedReaderPool(config) - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - - // Based on content length - if req.ContentLength > config.limit { - return echo.ErrStatusRequestEntityTooLarge - } - - // Based on content read - r := pool.Get().(*limitedReader) - r.Reset(req.Body, c) - defer pool.Put(r) - req.Body = r - - return next(c) - } - } -} - -func (r *limitedReader) Read(b []byte) (n int, err error) { - n, err = r.reader.Read(b) - r.read += int64(n) - if r.read > r.limit { - return n, echo.ErrStatusRequestEntityTooLarge - } - return -} - -func (r *limitedReader) Close() error { - return r.reader.Close() -} - -func (r *limitedReader) Reset(reader io.ReadCloser, context echo.Context) { - r.reader = reader - r.context = context - r.read = 0 -} - -func limitedReaderPool(c BodyLimitConfig) sync.Pool { - return sync.Pool{ - New: func() interface{} { - return &limitedReader{BodyLimitConfig: c} - }, - } -} diff --git a/vendor/github.com/labstack/echo/middleware/compress.go b/vendor/github.com/labstack/echo/middleware/compress.go deleted file mode 100644 index b876009c..00000000 --- a/vendor/github.com/labstack/echo/middleware/compress.go +++ /dev/null @@ -1,122 +0,0 @@ -package middleware - -import ( - "bufio" - "compress/gzip" - "io" - "io/ioutil" - "net" - "net/http" - "strings" - - "github.com/labstack/echo" -) - -type ( - // GzipConfig defines the config for Gzip middleware. - GzipConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Gzip compression level. - // Optional. Default value -1. - Level int `yaml:"level"` - } - - gzipResponseWriter struct { - io.Writer - http.ResponseWriter - } -) - -const ( - gzipScheme = "gzip" -) - -var ( - // DefaultGzipConfig is the default Gzip middleware config. - DefaultGzipConfig = GzipConfig{ - Skipper: DefaultSkipper, - Level: -1, - } -) - -// Gzip returns a middleware which compresses HTTP response using gzip compression -// scheme. -func Gzip() echo.MiddlewareFunc { - return GzipWithConfig(DefaultGzipConfig) -} - -// GzipWithConfig return Gzip middleware with config. -// See: `Gzip()`. -func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultGzipConfig.Skipper - } - if config.Level == 0 { - config.Level = DefaultGzipConfig.Level - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - res := c.Response() - res.Header().Add(echo.HeaderVary, echo.HeaderAcceptEncoding) - if strings.Contains(c.Request().Header.Get(echo.HeaderAcceptEncoding), gzipScheme) { - res.Header().Set(echo.HeaderContentEncoding, gzipScheme) // Issue #806 - rw := res.Writer - w, err := gzip.NewWriterLevel(rw, config.Level) - if err != nil { - return err - } - defer func() { - if res.Size == 0 { - if res.Header().Get(echo.HeaderContentEncoding) == gzipScheme { - res.Header().Del(echo.HeaderContentEncoding) - } - // We have to reset response to it's pristine state when - // nothing is written to body or error is returned. - // See issue #424, #407. - res.Writer = rw - w.Reset(ioutil.Discard) - } - w.Close() - }() - grw := &gzipResponseWriter{Writer: w, ResponseWriter: rw} - res.Writer = grw - } - return next(c) - } - } -} - -func (w *gzipResponseWriter) WriteHeader(code int) { - if code == http.StatusNoContent { // Issue #489 - w.ResponseWriter.Header().Del(echo.HeaderContentEncoding) - } - w.Header().Del(echo.HeaderContentLength) // Issue #444 - w.ResponseWriter.WriteHeader(code) -} - -func (w *gzipResponseWriter) Write(b []byte) (int, error) { - if w.Header().Get(echo.HeaderContentType) == "" { - w.Header().Set(echo.HeaderContentType, http.DetectContentType(b)) - } - return w.Writer.Write(b) -} - -func (w *gzipResponseWriter) Flush() { - w.Writer.(*gzip.Writer).Flush() -} - -func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - return w.ResponseWriter.(http.Hijacker).Hijack() -} - -func (w *gzipResponseWriter) CloseNotify() <-chan bool { - return w.ResponseWriter.(http.CloseNotifier).CloseNotify() -} diff --git a/vendor/github.com/labstack/echo/middleware/cors.go b/vendor/github.com/labstack/echo/middleware/cors.go deleted file mode 100644 index 771000a5..00000000 --- a/vendor/github.com/labstack/echo/middleware/cors.go +++ /dev/null @@ -1,139 +0,0 @@ -package middleware - -import ( - "net/http" - "strconv" - "strings" - - "github.com/labstack/echo" -) - -type ( - // CORSConfig defines the config for CORS middleware. - CORSConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // AllowOrigin defines a list of origins that may access the resource. - // Optional. Default value []string{"*"}. - AllowOrigins []string `yaml:"allow_origins"` - - // AllowMethods defines a list methods allowed when accessing the resource. - // This is used in response to a preflight request. - // Optional. Default value DefaultCORSConfig.AllowMethods. - AllowMethods []string `yaml:"allow_methods"` - - // AllowHeaders defines a list of request headers that can be used when - // making the actual request. This in response to a preflight request. - // Optional. Default value []string{}. - AllowHeaders []string `yaml:"allow_headers"` - - // AllowCredentials indicates whether or not the response to the request - // can be exposed when the credentials flag is true. When used as part of - // a response to a preflight request, this indicates whether or not the - // actual request can be made using credentials. - // Optional. Default value false. - AllowCredentials bool `yaml:"allow_credentials"` - - // ExposeHeaders defines a whitelist headers that clients are allowed to - // access. - // Optional. Default value []string{}. - ExposeHeaders []string `yaml:"expose_headers"` - - // MaxAge indicates how long (in seconds) the results of a preflight request - // can be cached. - // Optional. Default value 0. - MaxAge int `yaml:"max_age"` - } -) - -var ( - // DefaultCORSConfig is the default CORS middleware config. - DefaultCORSConfig = CORSConfig{ - Skipper: DefaultSkipper, - AllowOrigins: []string{"*"}, - AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE}, - } -) - -// CORS returns a Cross-Origin Resource Sharing (CORS) middleware. -// See: https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS -func CORS() echo.MiddlewareFunc { - return CORSWithConfig(DefaultCORSConfig) -} - -// CORSWithConfig returns a CORS middleware with config. -// See: `CORS()`. -func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultCORSConfig.Skipper - } - if len(config.AllowOrigins) == 0 { - config.AllowOrigins = DefaultCORSConfig.AllowOrigins - } - if len(config.AllowMethods) == 0 { - config.AllowMethods = DefaultCORSConfig.AllowMethods - } - - allowMethods := strings.Join(config.AllowMethods, ",") - allowHeaders := strings.Join(config.AllowHeaders, ",") - exposeHeaders := strings.Join(config.ExposeHeaders, ",") - maxAge := strconv.Itoa(config.MaxAge) - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - res := c.Response() - origin := req.Header.Get(echo.HeaderOrigin) - allowOrigin := "" - - // Check allowed origins - for _, o := range config.AllowOrigins { - if o == "*" || o == origin { - allowOrigin = o - break - } - } - - // Simple request - if req.Method != echo.OPTIONS { - res.Header().Add(echo.HeaderVary, echo.HeaderOrigin) - res.Header().Set(echo.HeaderAccessControlAllowOrigin, allowOrigin) - if config.AllowCredentials { - res.Header().Set(echo.HeaderAccessControlAllowCredentials, "true") - } - if exposeHeaders != "" { - res.Header().Set(echo.HeaderAccessControlExposeHeaders, exposeHeaders) - } - return next(c) - } - - // Preflight request - res.Header().Add(echo.HeaderVary, echo.HeaderOrigin) - res.Header().Add(echo.HeaderVary, echo.HeaderAccessControlRequestMethod) - res.Header().Add(echo.HeaderVary, echo.HeaderAccessControlRequestHeaders) - res.Header().Set(echo.HeaderAccessControlAllowOrigin, allowOrigin) - res.Header().Set(echo.HeaderAccessControlAllowMethods, allowMethods) - if config.AllowCredentials { - res.Header().Set(echo.HeaderAccessControlAllowCredentials, "true") - } - if allowHeaders != "" { - res.Header().Set(echo.HeaderAccessControlAllowHeaders, allowHeaders) - } else { - h := req.Header.Get(echo.HeaderAccessControlRequestHeaders) - if h != "" { - res.Header().Set(echo.HeaderAccessControlAllowHeaders, h) - } - } - if config.MaxAge > 0 { - res.Header().Set(echo.HeaderAccessControlMaxAge, maxAge) - } - return c.NoContent(http.StatusNoContent) - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/csrf.go b/vendor/github.com/labstack/echo/middleware/csrf.go deleted file mode 100644 index 5d1f4671..00000000 --- a/vendor/github.com/labstack/echo/middleware/csrf.go +++ /dev/null @@ -1,210 +0,0 @@ -package middleware - -import ( - "crypto/subtle" - "errors" - "net/http" - "strings" - "time" - - "github.com/labstack/echo" - "github.com/labstack/gommon/random" -) - -type ( - // CSRFConfig defines the config for CSRF middleware. - CSRFConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // TokenLength is the length of the generated token. - TokenLength uint8 `yaml:"token_length"` - // Optional. Default value 32. - - // TokenLookup is a string in the form of ":" that is used - // to extract token from the request. - // Optional. Default value "header:X-CSRF-Token". - // Possible values: - // - "header:" - // - "form:" - // - "query:" - TokenLookup string `yaml:"token_lookup"` - - // Context key to store generated CSRF token into context. - // Optional. Default value "csrf". - ContextKey string `yaml:"context_key"` - - // Name of the CSRF cookie. This cookie will store CSRF token. - // Optional. Default value "csrf". - CookieName string `yaml:"cookie_name"` - - // Domain of the CSRF cookie. - // Optional. Default value none. - CookieDomain string `yaml:"cookie_domain"` - - // Path of the CSRF cookie. - // Optional. Default value none. - CookiePath string `yaml:"cookie_path"` - - // Max age (in seconds) of the CSRF cookie. - // Optional. Default value 86400 (24hr). - CookieMaxAge int `yaml:"cookie_max_age"` - - // Indicates if CSRF cookie is secure. - // Optional. Default value false. - CookieSecure bool `yaml:"cookie_secure"` - - // Indicates if CSRF cookie is HTTP only. - // Optional. Default value false. - CookieHTTPOnly bool `yaml:"cookie_http_only"` - } - - // csrfTokenExtractor defines a function that takes `echo.Context` and returns - // either a token or an error. - csrfTokenExtractor func(echo.Context) (string, error) -) - -var ( - // DefaultCSRFConfig is the default CSRF middleware config. - DefaultCSRFConfig = CSRFConfig{ - Skipper: DefaultSkipper, - TokenLength: 32, - TokenLookup: "header:" + echo.HeaderXCSRFToken, - ContextKey: "csrf", - CookieName: "_csrf", - CookieMaxAge: 86400, - } -) - -// CSRF returns a Cross-Site Request Forgery (CSRF) middleware. -// See: https://en.wikipedia.org/wiki/Cross-site_request_forgery -func CSRF() echo.MiddlewareFunc { - c := DefaultCSRFConfig - return CSRFWithConfig(c) -} - -// CSRFWithConfig returns a CSRF middleware with config. -// See `CSRF()`. -func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultCSRFConfig.Skipper - } - if config.TokenLength == 0 { - config.TokenLength = DefaultCSRFConfig.TokenLength - } - if config.TokenLookup == "" { - config.TokenLookup = DefaultCSRFConfig.TokenLookup - } - if config.ContextKey == "" { - config.ContextKey = DefaultCSRFConfig.ContextKey - } - if config.CookieName == "" { - config.CookieName = DefaultCSRFConfig.CookieName - } - if config.CookieMaxAge == 0 { - config.CookieMaxAge = DefaultCSRFConfig.CookieMaxAge - } - - // Initialize - parts := strings.Split(config.TokenLookup, ":") - extractor := csrfTokenFromHeader(parts[1]) - switch parts[0] { - case "form": - extractor = csrfTokenFromForm(parts[1]) - case "query": - extractor = csrfTokenFromQuery(parts[1]) - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - k, err := c.Cookie(config.CookieName) - token := "" - - // Generate token - if err != nil { - token = random.String(config.TokenLength) - } else { - // Reuse token - token = k.Value - } - - switch req.Method { - case echo.GET, echo.HEAD, echo.OPTIONS, echo.TRACE: - default: - // Validate token only for requests which are not defined as 'safe' by RFC7231 - clientToken, err := extractor(c) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, err.Error()) - } - if !validateCSRFToken(token, clientToken) { - return echo.NewHTTPError(http.StatusForbidden, "invalid csrf token") - } - } - - // Set CSRF cookie - cookie := new(http.Cookie) - cookie.Name = config.CookieName - cookie.Value = token - if config.CookiePath != "" { - cookie.Path = config.CookiePath - } - if config.CookieDomain != "" { - cookie.Domain = config.CookieDomain - } - cookie.Expires = time.Now().Add(time.Duration(config.CookieMaxAge) * time.Second) - cookie.Secure = config.CookieSecure - cookie.HttpOnly = config.CookieHTTPOnly - c.SetCookie(cookie) - - // Store token in the context - c.Set(config.ContextKey, token) - - // Protect clients from caching the response - c.Response().Header().Add(echo.HeaderVary, echo.HeaderCookie) - - return next(c) - } - } -} - -// csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the -// provided request header. -func csrfTokenFromHeader(header string) csrfTokenExtractor { - return func(c echo.Context) (string, error) { - return c.Request().Header.Get(header), nil - } -} - -// csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the -// provided form parameter. -func csrfTokenFromForm(param string) csrfTokenExtractor { - return func(c echo.Context) (string, error) { - token := c.FormValue(param) - if token == "" { - return "", errors.New("missing csrf token in the form parameter") - } - return token, nil - } -} - -// csrfTokenFromQuery returns a `csrfTokenExtractor` that extracts token from the -// provided query parameter. -func csrfTokenFromQuery(param string) csrfTokenExtractor { - return func(c echo.Context) (string, error) { - token := c.QueryParam(param) - if token == "" { - return "", errors.New("missing csrf token in the query string") - } - return token, nil - } -} - -func validateCSRFToken(token, clientToken string) bool { - return subtle.ConstantTimeCompare([]byte(token), []byte(clientToken)) == 1 -} diff --git a/vendor/github.com/labstack/echo/middleware/jwt.go b/vendor/github.com/labstack/echo/middleware/jwt.go deleted file mode 100644 index e98040ae..00000000 --- a/vendor/github.com/labstack/echo/middleware/jwt.go +++ /dev/null @@ -1,199 +0,0 @@ -package middleware - -import ( - "fmt" - "net/http" - "reflect" - "strings" - - "github.com/dgrijalva/jwt-go" - "github.com/labstack/echo" -) - -type ( - // JWTConfig defines the config for JWT middleware. - JWTConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Signing key to validate token. - // Required. - SigningKey interface{} - - // Signing method, used to check token signing method. - // Optional. Default value HS256. - SigningMethod string - - // Context key to store user information from the token into context. - // Optional. Default value "user". - ContextKey string - - // Claims are extendable claims data defining token content. - // Optional. Default value jwt.MapClaims - Claims jwt.Claims - - // TokenLookup is a string in the form of ":" that is used - // to extract token from the request. - // Optional. Default value "header:Authorization". - // Possible values: - // - "header:" - // - "query:" - // - "cookie:" - TokenLookup string - - // AuthScheme to be used in the Authorization header. - // Optional. Default value "Bearer". - AuthScheme string - - keyFunc jwt.Keyfunc - } - - jwtExtractor func(echo.Context) (string, error) -) - -// Algorithms -const ( - AlgorithmHS256 = "HS256" -) - -// Errors -var ( - ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt") - ErrJWTInvalid = echo.NewHTTPError(http.StatusUnauthorized, "invalid or expired jwt") -) - -var ( - // DefaultJWTConfig is the default JWT auth middleware config. - DefaultJWTConfig = JWTConfig{ - Skipper: DefaultSkipper, - SigningMethod: AlgorithmHS256, - ContextKey: "user", - TokenLookup: "header:" + echo.HeaderAuthorization, - AuthScheme: "Bearer", - Claims: jwt.MapClaims{}, - } -) - -// JWT returns a JSON Web Token (JWT) auth middleware. -// -// For valid token, it sets the user in context and calls next handler. -// For invalid token, it returns "401 - Unauthorized" error. -// For missing token, it returns "400 - Bad Request" error. -// -// See: https://jwt.io/introduction -// See `JWTConfig.TokenLookup` -func JWT(key interface{}) echo.MiddlewareFunc { - c := DefaultJWTConfig - c.SigningKey = key - return JWTWithConfig(c) -} - -// JWTWithConfig returns a JWT auth middleware with config. -// See: `JWT()`. -func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultJWTConfig.Skipper - } - if config.SigningKey == nil { - panic("echo: jwt middleware requires signing key") - } - if config.SigningMethod == "" { - config.SigningMethod = DefaultJWTConfig.SigningMethod - } - if config.ContextKey == "" { - config.ContextKey = DefaultJWTConfig.ContextKey - } - if config.Claims == nil { - config.Claims = DefaultJWTConfig.Claims - } - if config.TokenLookup == "" { - config.TokenLookup = DefaultJWTConfig.TokenLookup - } - if config.AuthScheme == "" { - config.AuthScheme = DefaultJWTConfig.AuthScheme - } - config.keyFunc = func(t *jwt.Token) (interface{}, error) { - // Check the signing method - if t.Method.Alg() != config.SigningMethod { - return nil, fmt.Errorf("unexpected jwt signing method=%v", t.Header["alg"]) - } - return config.SigningKey, nil - } - - // Initialize - parts := strings.Split(config.TokenLookup, ":") - extractor := jwtFromHeader(parts[1], config.AuthScheme) - switch parts[0] { - case "query": - extractor = jwtFromQuery(parts[1]) - case "cookie": - extractor = jwtFromCookie(parts[1]) - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - auth, err := extractor(c) - if err != nil { - return err - } - token := new(jwt.Token) - // Issue #647, #656 - if _, ok := config.Claims.(jwt.MapClaims); ok { - token, err = jwt.Parse(auth, config.keyFunc) - } else { - t := reflect.ValueOf(config.Claims).Type().Elem() - claims := reflect.New(t).Interface().(jwt.Claims) - token, err = jwt.ParseWithClaims(auth, claims, config.keyFunc) - } - if err == nil && token.Valid { - // Store user information from token into context. - c.Set(config.ContextKey, token) - return next(c) - } - return &echo.HTTPError{ - Code: ErrJWTInvalid.Code, - Message: ErrJWTInvalid.Message, - Internal: err, - } - } - } -} - -// jwtFromHeader returns a `jwtExtractor` that extracts token from the request header. -func jwtFromHeader(header string, authScheme string) jwtExtractor { - return func(c echo.Context) (string, error) { - auth := c.Request().Header.Get(header) - l := len(authScheme) - if len(auth) > l+1 && auth[:l] == authScheme { - return auth[l+1:], nil - } - return "", ErrJWTMissing - } -} - -// jwtFromQuery returns a `jwtExtractor` that extracts token from the query string. -func jwtFromQuery(param string) jwtExtractor { - return func(c echo.Context) (string, error) { - token := c.QueryParam(param) - if token == "" { - return "", ErrJWTMissing - } - return token, nil - } -} - -// jwtFromCookie returns a `jwtExtractor` that extracts token from the named cookie. -func jwtFromCookie(name string) jwtExtractor { - return func(c echo.Context) (string, error) { - cookie, err := c.Cookie(name) - if err != nil { - return "", ErrJWTMissing - } - return cookie.Value, nil - } -} diff --git a/vendor/github.com/labstack/echo/middleware/key_auth.go b/vendor/github.com/labstack/echo/middleware/key_auth.go deleted file mode 100644 index c12f4ca9..00000000 --- a/vendor/github.com/labstack/echo/middleware/key_auth.go +++ /dev/null @@ -1,150 +0,0 @@ -package middleware - -import ( - "errors" - "net/http" - "strings" - - "github.com/labstack/echo" -) - -type ( - // KeyAuthConfig defines the config for KeyAuth middleware. - KeyAuthConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // KeyLookup is a string in the form of ":" that is used - // to extract key from the request. - // Optional. Default value "header:Authorization". - // Possible values: - // - "header:" - // - "query:" - // - "form:" - KeyLookup string `yaml:"key_lookup"` - - // AuthScheme to be used in the Authorization header. - // Optional. Default value "Bearer". - AuthScheme string - - // Validator is a function to validate key. - // Required. - Validator KeyAuthValidator - } - - // KeyAuthValidator defines a function to validate KeyAuth credentials. - KeyAuthValidator func(string, echo.Context) (bool, error) - - keyExtractor func(echo.Context) (string, error) -) - -var ( - // DefaultKeyAuthConfig is the default KeyAuth middleware config. - DefaultKeyAuthConfig = KeyAuthConfig{ - Skipper: DefaultSkipper, - KeyLookup: "header:" + echo.HeaderAuthorization, - AuthScheme: "Bearer", - } -) - -// KeyAuth returns an KeyAuth middleware. -// -// For valid key it calls the next handler. -// For invalid key, it sends "401 - Unauthorized" response. -// For missing key, it sends "400 - Bad Request" response. -func KeyAuth(fn KeyAuthValidator) echo.MiddlewareFunc { - c := DefaultKeyAuthConfig - c.Validator = fn - return KeyAuthWithConfig(c) -} - -// KeyAuthWithConfig returns an KeyAuth middleware with config. -// See `KeyAuth()`. -func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultKeyAuthConfig.Skipper - } - // Defaults - if config.AuthScheme == "" { - config.AuthScheme = DefaultKeyAuthConfig.AuthScheme - } - if config.KeyLookup == "" { - config.KeyLookup = DefaultKeyAuthConfig.KeyLookup - } - if config.Validator == nil { - panic("echo: key-auth middleware requires a validator function") - } - - // Initialize - parts := strings.Split(config.KeyLookup, ":") - extractor := keyFromHeader(parts[1], config.AuthScheme) - switch parts[0] { - case "query": - extractor = keyFromQuery(parts[1]) - case "form": - extractor = keyFromForm(parts[1]) - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - // Extract and verify key - key, err := extractor(c) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, err.Error()) - } - valid, err := config.Validator(key, c) - if err != nil { - return err - } else if valid { - return next(c) - } - - return echo.ErrUnauthorized - } - } -} - -// keyFromHeader returns a `keyExtractor` that extracts key from the request header. -func keyFromHeader(header string, authScheme string) keyExtractor { - return func(c echo.Context) (string, error) { - auth := c.Request().Header.Get(header) - if auth == "" { - return "", errors.New("missing key in request header") - } - if header == echo.HeaderAuthorization { - l := len(authScheme) - if len(auth) > l+1 && auth[:l] == authScheme { - return auth[l+1:], nil - } - return "", errors.New("invalid key in the request header") - } - return auth, nil - } -} - -// keyFromQuery returns a `keyExtractor` that extracts key from the query string. -func keyFromQuery(param string) keyExtractor { - return func(c echo.Context) (string, error) { - key := c.QueryParam(param) - if key == "" { - return "", errors.New("missing key in the query string") - } - return key, nil - } -} - -// keyFromForm returns a `keyExtractor` that extracts key from the form. -func keyFromForm(param string) keyExtractor { - return func(c echo.Context) (string, error) { - key := c.FormValue(param) - if key == "" { - return "", errors.New("missing key in the form") - } - return key, nil - } -} diff --git a/vendor/github.com/labstack/echo/middleware/logger.go b/vendor/github.com/labstack/echo/middleware/logger.go deleted file mode 100644 index 87af575f..00000000 --- a/vendor/github.com/labstack/echo/middleware/logger.go +++ /dev/null @@ -1,209 +0,0 @@ -package middleware - -import ( - "bytes" - "io" - "os" - "strconv" - "strings" - "sync" - "time" - - "github.com/labstack/echo" - "github.com/labstack/gommon/color" - "github.com/valyala/fasttemplate" -) - -type ( - // LoggerConfig defines the config for Logger middleware. - LoggerConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Tags to constructed the logger format. - // - // - time_unix - // - time_unix_nano - // - time_rfc3339 - // - time_rfc3339_nano - // - time_custom - // - id (Request ID) - // - remote_ip - // - uri - // - host - // - method - // - path - // - referer - // - user_agent - // - status - // - latency (In nanoseconds) - // - latency_human (Human readable) - // - bytes_in (Bytes received) - // - bytes_out (Bytes sent) - // - header: - // - query: - // - form: - // - // Example "${remote_ip} ${status}" - // - // Optional. Default value DefaultLoggerConfig.Format. - Format string `yaml:"format"` - - // Optional. Default value DefaultLoggerConfig.CustomTimeFormat. - CustomTimeFormat string `yaml:"custom_time_format"` - - // Output is a writer where logs in JSON format are written. - // Optional. Default value os.Stdout. - Output io.Writer - - template *fasttemplate.Template - colorer *color.Color - pool *sync.Pool - } -) - -var ( - // DefaultLoggerConfig is the default Logger middleware config. - DefaultLoggerConfig = LoggerConfig{ - Skipper: DefaultSkipper, - Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}","host":"${host}",` + - `"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` + - `"latency_human":"${latency_human}","bytes_in":${bytes_in},` + - `"bytes_out":${bytes_out}}` + "\n", - CustomTimeFormat: "2006-01-02 15:04:05.00000", - Output: os.Stdout, - colorer: color.New(), - } -) - -// Logger returns a middleware that logs HTTP requests. -func Logger() echo.MiddlewareFunc { - return LoggerWithConfig(DefaultLoggerConfig) -} - -// LoggerWithConfig returns a Logger middleware with config. -// See: `Logger()`. -func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultLoggerConfig.Skipper - } - if config.Format == "" { - config.Format = DefaultLoggerConfig.Format - } - if config.Output == nil { - config.Output = DefaultLoggerConfig.Output - } - - config.template = fasttemplate.New(config.Format, "${", "}") - config.colorer = color.New() - config.colorer.SetOutput(config.Output) - config.pool = &sync.Pool{ - New: func() interface{} { - return bytes.NewBuffer(make([]byte, 256)) - }, - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) (err error) { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - res := c.Response() - start := time.Now() - if err = next(c); err != nil { - c.Error(err) - } - stop := time.Now() - buf := config.pool.Get().(*bytes.Buffer) - buf.Reset() - defer config.pool.Put(buf) - - if _, err = config.template.ExecuteFunc(buf, func(w io.Writer, tag string) (int, error) { - switch tag { - case "time_unix": - return buf.WriteString(strconv.FormatInt(time.Now().Unix(), 10)) - case "time_unix_nano": - return buf.WriteString(strconv.FormatInt(time.Now().UnixNano(), 10)) - case "time_rfc3339": - return buf.WriteString(time.Now().Format(time.RFC3339)) - case "time_rfc3339_nano": - return buf.WriteString(time.Now().Format(time.RFC3339Nano)) - case "time_custom": - return buf.WriteString(time.Now().Format(config.CustomTimeFormat)) - case "id": - id := req.Header.Get(echo.HeaderXRequestID) - if id == "" { - id = res.Header().Get(echo.HeaderXRequestID) - } - return buf.WriteString(id) - case "remote_ip": - return buf.WriteString(c.RealIP()) - case "host": - return buf.WriteString(req.Host) - case "uri": - return buf.WriteString(req.RequestURI) - case "method": - return buf.WriteString(req.Method) - case "path": - p := req.URL.Path - if p == "" { - p = "/" - } - return buf.WriteString(p) - case "referer": - return buf.WriteString(req.Referer()) - case "user_agent": - return buf.WriteString(req.UserAgent()) - case "status": - n := res.Status - s := config.colorer.Green(n) - switch { - case n >= 500: - s = config.colorer.Red(n) - case n >= 400: - s = config.colorer.Yellow(n) - case n >= 300: - s = config.colorer.Cyan(n) - } - return buf.WriteString(s) - case "latency": - l := stop.Sub(start) - return buf.WriteString(strconv.FormatInt(int64(l), 10)) - case "latency_human": - return buf.WriteString(stop.Sub(start).String()) - case "bytes_in": - cl := req.Header.Get(echo.HeaderContentLength) - if cl == "" { - cl = "0" - } - return buf.WriteString(cl) - case "bytes_out": - return buf.WriteString(strconv.FormatInt(res.Size, 10)) - default: - switch { - case strings.HasPrefix(tag, "header:"): - return buf.Write([]byte(c.Request().Header.Get(tag[7:]))) - case strings.HasPrefix(tag, "query:"): - return buf.Write([]byte(c.QueryParam(tag[6:]))) - case strings.HasPrefix(tag, "form:"): - return buf.Write([]byte(c.FormValue(tag[5:]))) - case strings.HasPrefix(tag, "cookie:"): - cookie, err := c.Cookie(tag[7:]) - if err == nil { - return buf.Write([]byte(cookie.Value)) - } - } - } - return 0, nil - }); err != nil { - return - } - - _, err = config.Output.Write(buf.Bytes()) - return - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/method_override.go b/vendor/github.com/labstack/echo/middleware/method_override.go deleted file mode 100644 index 955fd11e..00000000 --- a/vendor/github.com/labstack/echo/middleware/method_override.go +++ /dev/null @@ -1,88 +0,0 @@ -package middleware - -import "github.com/labstack/echo" - -type ( - // MethodOverrideConfig defines the config for MethodOverride middleware. - MethodOverrideConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Getter is a function that gets overridden method from the request. - // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride). - Getter MethodOverrideGetter - } - - // MethodOverrideGetter is a function that gets overridden method from the request - MethodOverrideGetter func(echo.Context) string -) - -var ( - // DefaultMethodOverrideConfig is the default MethodOverride middleware config. - DefaultMethodOverrideConfig = MethodOverrideConfig{ - Skipper: DefaultSkipper, - Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride), - } -) - -// MethodOverride returns a MethodOverride middleware. -// MethodOverride middleware checks for the overridden method from the request and -// uses it instead of the original method. -// -// For security reasons, only `POST` method can be overridden. -func MethodOverride() echo.MiddlewareFunc { - return MethodOverrideWithConfig(DefaultMethodOverrideConfig) -} - -// MethodOverrideWithConfig returns a MethodOverride middleware with config. -// See: `MethodOverride()`. -func MethodOverrideWithConfig(config MethodOverrideConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultMethodOverrideConfig.Skipper - } - if config.Getter == nil { - config.Getter = DefaultMethodOverrideConfig.Getter - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - if req.Method == echo.POST { - m := config.Getter(c) - if m != "" { - req.Method = m - } - } - return next(c) - } - } -} - -// MethodFromHeader is a `MethodOverrideGetter` that gets overridden method from -// the request header. -func MethodFromHeader(header string) MethodOverrideGetter { - return func(c echo.Context) string { - return c.Request().Header.Get(header) - } -} - -// MethodFromForm is a `MethodOverrideGetter` that gets overridden method from the -// form parameter. -func MethodFromForm(param string) MethodOverrideGetter { - return func(c echo.Context) string { - return c.FormValue(param) - } -} - -// MethodFromQuery is a `MethodOverrideGetter` that gets overridden method from -// the query parameter. -func MethodFromQuery(param string) MethodOverrideGetter { - return func(c echo.Context) string { - return c.QueryParam(param) - } -} diff --git a/vendor/github.com/labstack/echo/middleware/middleware.go b/vendor/github.com/labstack/echo/middleware/middleware.go deleted file mode 100644 index 71f95db7..00000000 --- a/vendor/github.com/labstack/echo/middleware/middleware.go +++ /dev/null @@ -1,35 +0,0 @@ -package middleware - -import ( - "regexp" - "strconv" - "strings" - - "github.com/labstack/echo" -) - -type ( - // Skipper defines a function to skip middleware. Returning true skips processing - // the middleware. - Skipper func(c echo.Context) bool -) - -func captureTokens(pattern *regexp.Regexp, input string) *strings.Replacer { - groups := pattern.FindAllStringSubmatch(input, -1) - if groups == nil { - return nil - } - values := groups[0][1:] - replace := make([]string, 2*len(values)) - for i, v := range values { - j := 2 * i - replace[j] = "$" + strconv.Itoa(i+1) - replace[j+1] = v - } - return strings.NewReplacer(replace...) -} - -// DefaultSkipper returns false which processes the middleware. -func DefaultSkipper(echo.Context) bool { - return false -} diff --git a/vendor/github.com/labstack/echo/middleware/proxy.go b/vendor/github.com/labstack/echo/middleware/proxy.go deleted file mode 100644 index f6147737..00000000 --- a/vendor/github.com/labstack/echo/middleware/proxy.go +++ /dev/null @@ -1,252 +0,0 @@ -package middleware - -import ( - "fmt" - "io" - "math/rand" - "net" - "net/http" - "net/http/httputil" - "net/url" - "regexp" - "strings" - "sync" - "sync/atomic" - "time" - - "github.com/labstack/echo" -) - -// TODO: Handle TLS proxy - -type ( - // ProxyConfig defines the config for Proxy middleware. - ProxyConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Balancer defines a load balancing technique. - // Required. - Balancer ProxyBalancer - - // Rewrite defines URL path rewrite rules. The values captured in asterisk can be - // retrieved by index e.g. $1, $2 and so on. - // Examples: - // "/old": "/new", - // "/api/*": "/$1", - // "/js/*": "/public/javascripts/$1", - // "/users/*/orders/*": "/user/$1/order/$2", - Rewrite map[string]string - - rewriteRegex map[*regexp.Regexp]string - } - - // ProxyTarget defines the upstream target. - ProxyTarget struct { - Name string - URL *url.URL - } - - // ProxyBalancer defines an interface to implement a load balancing technique. - ProxyBalancer interface { - AddTarget(*ProxyTarget) bool - RemoveTarget(string) bool - Next() *ProxyTarget - } - - commonBalancer struct { - targets []*ProxyTarget - mutex sync.RWMutex - } - - // RandomBalancer implements a random load balancing technique. - randomBalancer struct { - *commonBalancer - random *rand.Rand - } - - // RoundRobinBalancer implements a round-robin load balancing technique. - roundRobinBalancer struct { - *commonBalancer - i uint32 - } -) - -var ( - // DefaultProxyConfig is the default Proxy middleware config. - DefaultProxyConfig = ProxyConfig{ - Skipper: DefaultSkipper, - } -) - -func proxyHTTP(t *ProxyTarget) http.Handler { - return httputil.NewSingleHostReverseProxy(t.URL) -} - -func proxyRaw(t *ProxyTarget, c echo.Context) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - in, _, err := c.Response().Hijack() - if err != nil { - c.Error(fmt.Errorf("proxy raw, hijack error=%v, url=%s", t.URL, err)) - return - } - defer in.Close() - - out, err := net.Dial("tcp", t.URL.Host) - if err != nil { - he := echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, dial error=%v, url=%s", t.URL, err)) - c.Error(he) - return - } - defer out.Close() - - // Write header - err = r.Write(out) - if err != nil { - he := echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, request header copy error=%v, url=%s", t.URL, err)) - c.Error(he) - return - } - - errCh := make(chan error, 2) - cp := func(dst io.Writer, src io.Reader) { - _, err = io.Copy(dst, src) - errCh <- err - } - - go cp(out, in) - go cp(in, out) - err = <-errCh - if err != nil && err != io.EOF { - c.Logger().Errorf("proxy raw, copy body error=%v, url=%s", t.URL, err) - } - }) -} - -// NewRandomBalancer returns a random proxy balancer. -func NewRandomBalancer(targets []*ProxyTarget) ProxyBalancer { - b := &randomBalancer{commonBalancer: new(commonBalancer)} - b.targets = targets - return b -} - -// NewRoundRobinBalancer returns a round-robin proxy balancer. -func NewRoundRobinBalancer(targets []*ProxyTarget) ProxyBalancer { - b := &roundRobinBalancer{commonBalancer: new(commonBalancer)} - b.targets = targets - return b -} - -// AddTarget adds an upstream target to the list. -func (b *commonBalancer) AddTarget(target *ProxyTarget) bool { - for _, t := range b.targets { - if t.Name == target.Name { - return false - } - } - b.mutex.Lock() - defer b.mutex.Unlock() - b.targets = append(b.targets, target) - return true -} - -// RemoveTarget removes an upstream target from the list. -func (b *commonBalancer) RemoveTarget(name string) bool { - b.mutex.Lock() - defer b.mutex.Unlock() - for i, t := range b.targets { - if t.Name == name { - b.targets = append(b.targets[:i], b.targets[i+1:]...) - return true - } - } - return false -} - -// Next randomly returns an upstream target. -func (b *randomBalancer) Next() *ProxyTarget { - if b.random == nil { - b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond()))) - } - b.mutex.RLock() - defer b.mutex.RUnlock() - return b.targets[b.random.Intn(len(b.targets))] -} - -// Next returns an upstream target using round-robin technique. -func (b *roundRobinBalancer) Next() *ProxyTarget { - b.i = b.i % uint32(len(b.targets)) - t := b.targets[b.i] - atomic.AddUint32(&b.i, 1) - return t -} - -// Proxy returns a Proxy middleware. -// -// Proxy middleware forwards the request to upstream server using a configured load balancing technique. -func Proxy(balancer ProxyBalancer) echo.MiddlewareFunc { - c := DefaultProxyConfig - c.Balancer = balancer - return ProxyWithConfig(c) -} - -// ProxyWithConfig returns a Proxy middleware with config. -// See: `Proxy()` -func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultLoggerConfig.Skipper - } - if config.Balancer == nil { - panic("echo: proxy middleware requires balancer") - } - config.rewriteRegex = map[*regexp.Regexp]string{} - - // Initialize - for k, v := range config.Rewrite { - k = strings.Replace(k, "*", "(\\S*)", -1) - config.rewriteRegex[regexp.MustCompile(k)] = v - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) (err error) { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - res := c.Response() - tgt := config.Balancer.Next() - - // Rewrite - for k, v := range config.rewriteRegex { - replacer := captureTokens(k, req.URL.Path) - if replacer != nil { - req.URL.Path = replacer.Replace(v) - } - } - - // Fix header - if req.Header.Get(echo.HeaderXRealIP) == "" { - req.Header.Set(echo.HeaderXRealIP, c.RealIP()) - } - if req.Header.Get(echo.HeaderXForwardedProto) == "" { - req.Header.Set(echo.HeaderXForwardedProto, c.Scheme()) - } - if c.IsWebSocket() && req.Header.Get(echo.HeaderXForwardedFor) == "" { // For HTTP, it is automatically set by Go HTTP reverse proxy. - req.Header.Set(echo.HeaderXForwardedFor, c.RealIP()) - } - - // Proxy - switch { - case c.IsWebSocket(): - proxyRaw(tgt, c).ServeHTTP(res, req) - case req.Header.Get(echo.HeaderAccept) == "text/event-stream": - default: - proxyHTTP(tgt).ServeHTTP(res, req) - } - - return - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/recover.go b/vendor/github.com/labstack/echo/middleware/recover.go deleted file mode 100644 index 2a42c5b1..00000000 --- a/vendor/github.com/labstack/echo/middleware/recover.go +++ /dev/null @@ -1,81 +0,0 @@ -package middleware - -import ( - "fmt" - "runtime" - - "github.com/labstack/echo" -) - -type ( - // RecoverConfig defines the config for Recover middleware. - RecoverConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Size of the stack to be printed. - // Optional. Default value 4KB. - StackSize int `yaml:"stack_size"` - - // DisableStackAll disables formatting stack traces of all other goroutines - // into buffer after the trace for the current goroutine. - // Optional. Default value false. - DisableStackAll bool `yaml:"disable_stack_all"` - - // DisablePrintStack disables printing stack trace. - // Optional. Default value as false. - DisablePrintStack bool `yaml:"disable_print_stack"` - } -) - -var ( - // DefaultRecoverConfig is the default Recover middleware config. - DefaultRecoverConfig = RecoverConfig{ - Skipper: DefaultSkipper, - StackSize: 4 << 10, // 4 KB - DisableStackAll: false, - DisablePrintStack: false, - } -) - -// Recover returns a middleware which recovers from panics anywhere in the chain -// and handles the control to the centralized HTTPErrorHandler. -func Recover() echo.MiddlewareFunc { - return RecoverWithConfig(DefaultRecoverConfig) -} - -// RecoverWithConfig returns a Recover middleware with config. -// See: `Recover()`. -func RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultRecoverConfig.Skipper - } - if config.StackSize == 0 { - config.StackSize = DefaultRecoverConfig.StackSize - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - defer func() { - if r := recover(); r != nil { - err, ok := r.(error) - if !ok { - err = fmt.Errorf("%v", r) - } - stack := make([]byte, config.StackSize) - length := runtime.Stack(stack, !config.DisableStackAll) - if !config.DisablePrintStack { - c.Logger().Printf("[PANIC RECOVER] %v %s\n", err, stack[:length]) - } - c.Error(err) - } - }() - return next(c) - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/redirect.go b/vendor/github.com/labstack/echo/middleware/redirect.go deleted file mode 100644 index 422263de..00000000 --- a/vendor/github.com/labstack/echo/middleware/redirect.go +++ /dev/null @@ -1,153 +0,0 @@ -package middleware - -import ( - "net/http" - - "github.com/labstack/echo" -) - -// RedirectConfig defines the config for Redirect middleware. -type RedirectConfig struct { - // Skipper defines a function to skip middleware. - Skipper - - // Status code to be used when redirecting the request. - // Optional. Default value http.StatusMovedPermanently. - Code int `yaml:"code"` -} - -// redirectLogic represents a function that given a scheme, host and uri -// can both: 1) determine if redirect is needed (will set ok accordingly) and -// 2) return the appropriate redirect url. -type redirectLogic func(scheme, host, uri string) (ok bool, url string) - -const www = "www" - -// DefaultRedirectConfig is the default Redirect middleware config. -var DefaultRedirectConfig = RedirectConfig{ - Skipper: DefaultSkipper, - Code: http.StatusMovedPermanently, -} - -// HTTPSRedirect redirects http requests to https. -// For example, http://labstack.com will be redirect to https://labstack.com. -// -// Usage `Echo#Pre(HTTPSRedirect())` -func HTTPSRedirect() echo.MiddlewareFunc { - return HTTPSRedirectWithConfig(DefaultRedirectConfig) -} - -// HTTPSRedirectWithConfig returns an HTTPSRedirect middleware with config. -// See `HTTPSRedirect()`. -func HTTPSRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https"; ok { - url = "https://" + host + uri - } - return - }) -} - -// HTTPSWWWRedirect redirects http requests to https www. -// For example, http://labstack.com will be redirect to https://www.labstack.com. -// -// Usage `Echo#Pre(HTTPSWWWRedirect())` -func HTTPSWWWRedirect() echo.MiddlewareFunc { - return HTTPSWWWRedirectWithConfig(DefaultRedirectConfig) -} - -// HTTPSWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. -// See `HTTPSWWWRedirect()`. -func HTTPSWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https" && host[:3] != www; ok { - url = "https://www." + host + uri - } - return - }) -} - -// HTTPSNonWWWRedirect redirects http requests to https non www. -// For example, http://www.labstack.com will be redirect to https://labstack.com. -// -// Usage `Echo#Pre(HTTPSNonWWWRedirect())` -func HTTPSNonWWWRedirect() echo.MiddlewareFunc { - return HTTPSNonWWWRedirectWithConfig(DefaultRedirectConfig) -} - -// HTTPSNonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. -// See `HTTPSNonWWWRedirect()`. -func HTTPSNonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = scheme != "https"; ok { - if host[:3] == www { - host = host[4:] - } - url = "https://" + host + uri - } - return - }) -} - -// WWWRedirect redirects non www requests to www. -// For example, http://labstack.com will be redirect to http://www.labstack.com. -// -// Usage `Echo#Pre(WWWRedirect())` -func WWWRedirect() echo.MiddlewareFunc { - return WWWRedirectWithConfig(DefaultRedirectConfig) -} - -// WWWRedirectWithConfig returns an HTTPSRedirect middleware with config. -// See `WWWRedirect()`. -func WWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = host[:3] != www; ok { - url = scheme + "://www." + host + uri - } - return - }) -} - -// NonWWWRedirect redirects www requests to non www. -// For example, http://www.labstack.com will be redirect to http://labstack.com. -// -// Usage `Echo#Pre(NonWWWRedirect())` -func NonWWWRedirect() echo.MiddlewareFunc { - return NonWWWRedirectWithConfig(DefaultRedirectConfig) -} - -// NonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. -// See `NonWWWRedirect()`. -func NonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc { - return redirect(config, func(scheme, host, uri string) (ok bool, url string) { - if ok = host[:3] == www; ok { - url = scheme + "://" + host[4:] + uri - } - return - }) -} - -func redirect(config RedirectConfig, cb redirectLogic) echo.MiddlewareFunc { - if config.Skipper == nil { - config.Skipper = DefaultTrailingSlashConfig.Skipper - } - if config.Code == 0 { - config.Code = DefaultRedirectConfig.Code - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req, scheme := c.Request(), c.Scheme() - host := req.Host - if ok, url := cb(scheme, host, req.RequestURI); ok { - return c.Redirect(config.Code, url) - } - - return next(c) - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/request_id.go b/vendor/github.com/labstack/echo/middleware/request_id.go deleted file mode 100644 index f376c296..00000000 --- a/vendor/github.com/labstack/echo/middleware/request_id.go +++ /dev/null @@ -1,64 +0,0 @@ -package middleware - -import ( - "github.com/labstack/echo" - "github.com/labstack/gommon/random" -) - -type ( - // RequestIDConfig defines the config for RequestID middleware. - RequestIDConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Generator defines a function to generate an ID. - // Optional. Default value random.String(32). - Generator func() string - } -) - -var ( - // DefaultRequestIDConfig is the default RequestID middleware config. - DefaultRequestIDConfig = RequestIDConfig{ - Skipper: DefaultSkipper, - Generator: generator, - } -) - -// RequestID returns a X-Request-ID middleware. -func RequestID() echo.MiddlewareFunc { - return RequestIDWithConfig(DefaultRequestIDConfig) -} - -// RequestIDWithConfig returns a X-Request-ID middleware with config. -func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc { - // Defaults - if config.Skipper == nil { - config.Skipper = DefaultRequestIDConfig.Skipper - } - if config.Generator == nil { - config.Generator = generator - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) error { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - res := c.Response() - rid := req.Header.Get(echo.HeaderXRequestID) - if rid == "" { - rid = config.Generator() - } - res.Header().Set(echo.HeaderXRequestID, rid) - - return next(c) - } - } -} - -func generator() string { - return random.String(32) -} diff --git a/vendor/github.com/labstack/echo/middleware/rewrite.go b/vendor/github.com/labstack/echo/middleware/rewrite.go deleted file mode 100644 index 60a59bec..00000000 --- a/vendor/github.com/labstack/echo/middleware/rewrite.go +++ /dev/null @@ -1,83 +0,0 @@ -package middleware - -import ( - "regexp" - "strings" - - "github.com/labstack/echo" -) - -type ( - // RewriteConfig defines the config for Rewrite middleware. - RewriteConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // Rules defines the URL path rewrite rules. The values captured in asterisk can be - // retrieved by index e.g. $1, $2 and so on. - // Example: - // "/old": "/new", - // "/api/*": "/$1", - // "/js/*": "/public/javascripts/$1", - // "/users/*/orders/*": "/user/$1/order/$2", - // Required. - Rules map[string]string `yaml:"rules"` - - rulesRegex map[*regexp.Regexp]string - } -) - -var ( - // DefaultRewriteConfig is the default Rewrite middleware config. - DefaultRewriteConfig = RewriteConfig{ - Skipper: DefaultSkipper, - } -) - -// Rewrite returns a Rewrite middleware. -// -// Rewrite middleware rewrites the URL path based on the provided rules. -func Rewrite(rules map[string]string) echo.MiddlewareFunc { - c := DefaultRewriteConfig - c.Rules = rules - return RewriteWithConfig(c) -} - -// RewriteWithConfig returns a Rewrite middleware with config. -// See: `Rewrite()`. -func RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc { - // Defaults - if config.Rules == nil { - panic("echo: rewrite middleware requires url path rewrite rules") - } - if config.Skipper == nil { - config.Skipper = DefaultBodyDumpConfig.Skipper - } - config.rulesRegex = map[*regexp.Regexp]string{} - - // Initialize - for k, v := range config.Rules { - k = strings.Replace(k, "*", "(\\S*)", -1) - config.rulesRegex[regexp.MustCompile(k)] = v - } - - return func(next echo.HandlerFunc) echo.HandlerFunc { - return func(c echo.Context) (err error) { - if config.Skipper(c) { - return next(c) - } - - req := c.Request() - - // Rewrite - for k, v := range config.rulesRegex { - replacer := captureTokens(k, req.URL.Path) - if replacer != nil { - req.URL.Path = replacer.Replace(v) - } - } - - return next(c) - } - } -} diff --git a/vendor/github.com/labstack/echo/middleware/secure.go b/vendor/github.com/labstack/echo/middleware/secure.go deleted file mode 100644 index 188c0c40..00000000 --- a/vendor/github.com/labstack/echo/middleware/secure.go +++ /dev/null @@ -1,116 +0,0 @@ -package middleware - -import ( - "fmt" - - "github.com/labstack/echo" -) - -type ( - // SecureConfig defines the config for Secure middleware. - SecureConfig struct { - // Skipper defines a function to skip middleware. - Skipper Skipper - - // XSSProtection provides protection against cross-site scripting attack (XSS) - // by setting the `X-XSS-Protection` header. - // Optional. Default value "1; mode=block". - XSSProtection string `yaml:"xss_protection"` - - // ContentTypeNosniff provides protection against overriding Content-Type - // header by setting the `X-Content-Type-Options` header. - // Optional. Default value "nosniff". - ContentTypeNosniff string `yaml:"content_type_nosniff"` - - // XFrameOptions can be used to indicate whether or not a browser should - // be allowed to render a page in a ,