mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
update depndencies
This commit is contained in:
parent
126b13fcea
commit
9accd685c0
67
Gopkg.lock
generated
67
Gopkg.lock
generated
@ -28,7 +28,10 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/gin-contrib/sessions"
|
name = "github.com/gin-contrib/sessions"
|
||||||
packages = ["."]
|
packages = [
|
||||||
|
".",
|
||||||
|
"cookie"
|
||||||
|
]
|
||||||
revision = "854e10e72056b122034a60b0fa207b8f29ae3d07"
|
revision = "854e10e72056b122034a60b0fa207b8f29ae3d07"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
@ -39,15 +42,20 @@
|
|||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/gin-gonic/gin"
|
name = "github.com/gin-gonic/gin"
|
||||||
packages = [".","binding","render"]
|
packages = [
|
||||||
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
".",
|
||||||
version = "v1.2"
|
"binding",
|
||||||
|
"json",
|
||||||
|
"render"
|
||||||
|
]
|
||||||
|
revision = "b869fe1415e4b9eb52f247441830d502aece2d4d"
|
||||||
|
version = "v1.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/golang/protobuf"
|
name = "github.com/golang/protobuf"
|
||||||
packages = ["proto"]
|
packages = ["proto"]
|
||||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
|
||||||
version = "v1.1.0"
|
version = "v1.2.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/gorilla/context"
|
name = "github.com/gorilla/context"
|
||||||
@ -73,6 +81,12 @@
|
|||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "dd349441af25132d146d7095c6693a15431fc9b1"
|
revision = "dd349441af25132d146d7095c6693a15431fc9b1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/json-iterator/go"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "1624edc4454b8682399def8740d46db5e4362ba4"
|
||||||
|
version = "1.1.5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/mattn/go-isatty"
|
name = "github.com/mattn/go-isatty"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
@ -82,8 +96,20 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/microcosm-cc/bluemonday"
|
name = "github.com/microcosm-cc/bluemonday"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "dafebb5b6ff2861a0d69af64991e10866c19be85"
|
revision = "82c7118e8ccf7403d4860175d97bb635e8e28239"
|
||||||
version = "v1.0.0"
|
version = "v1.0.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/modern-go/concurrent"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94"
|
||||||
|
version = "1.0.3"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/modern-go/reflect2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
|
||||||
|
version = "1.0.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/russross/blackfriday"
|
name = "github.com/russross/blackfriday"
|
||||||
@ -118,7 +144,12 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/shurcooL/go"
|
name = "github.com/shurcooL/go"
|
||||||
packages = ["parserutil","printerutil","reflectfind","reflectsource"]
|
packages = [
|
||||||
|
"parserutil",
|
||||||
|
"printerutil",
|
||||||
|
"reflectfind",
|
||||||
|
"reflectsource"
|
||||||
|
]
|
||||||
revision = "9e1955d9fb6e1ee2345ba1f5e71669263e719e27"
|
revision = "9e1955d9fb6e1ee2345ba1f5e71669263e719e27"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
@ -178,20 +209,26 @@
|
|||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = ["bcrypt","blowfish"]
|
packages = [
|
||||||
revision = "c126467f60eb25f8f27e5a981f32a87e3965053f"
|
"bcrypt",
|
||||||
|
"blowfish"
|
||||||
|
]
|
||||||
|
revision = "614d502a4dac94afa3a6ce146bd1736da82514c6"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/net"
|
name = "golang.org/x/net"
|
||||||
packages = ["html","html/atom"]
|
packages = [
|
||||||
revision = "49c15d80dfbc983ea25246ee959d970efe09ec09"
|
"html",
|
||||||
|
"html/atom"
|
||||||
|
]
|
||||||
|
revision = "922f4815f713f213882e8ef45e0d315b164d705c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = ["unix"]
|
packages = ["unix"]
|
||||||
revision = "bd9dbc187b6e1dacfdd2722a87e83093c2d7bd6e"
|
revision = "3b58ed4ad3395d483fc92d5d14123ce2c3581fec"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/go-playground/validator.v8"
|
name = "gopkg.in/go-playground/validator.v8"
|
||||||
@ -214,6 +251,6 @@
|
|||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "bba58de7dff48236cb5072c4b9168d65215929b3194bef8bb0f6fe155b77192e"
|
inputs-digest = "2bf547daebec24c2659277321ce23577e526a4b96aa9051cd4ca1f17669b54a6"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
@ -131,7 +131,7 @@ func staticCssBaseMinCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/base-min.css", size: 2195, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/base-min.css", size: 2195, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ func staticCssDefaultCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/default.css", size: 2476, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/default.css", size: 2476, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func staticCssDropzoneCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/dropzone.css", size: 12587, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/dropzone.css", size: 12587, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ func staticCssGithubMarkdownCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/github-markdown.css", size: 11557, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/github-markdown.css", size: 11557, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ func staticCssHighlightCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/highlight.css", size: 776, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/highlight.css", size: 776, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ func staticCssMenusMinCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/css/menus-min.css", size: 2471, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/css/menus-min.css", size: 2471, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ func staticImgCowyoAndroidIcon144x144Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ func staticImgCowyoAndroidIcon192x192Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-192x192.png", size: 8200, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-192x192.png", size: 8200, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ func staticImgCowyoAndroidIcon36x36Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-36x36.png", size: 1952, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-36x36.png", size: 1952, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ func staticImgCowyoAndroidIcon48x48Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-48x48.png", size: 2451, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-48x48.png", size: 2451, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ func staticImgCowyoAndroidIcon72x72Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-72x72.png", size: 3317, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-72x72.png", size: 3317, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -351,7 +351,7 @@ func staticImgCowyoAndroidIcon96x96Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/android-icon-96x96.png", size: 4296, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/android-icon-96x96.png", size: 4296, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ func staticImgCowyoAppleIcon114x114Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-114x114.png", size: 5015, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-114x114.png", size: 5015, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ func staticImgCowyoAppleIcon120x120Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-120x120.png", size: 5365, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-120x120.png", size: 5365, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ func staticImgCowyoAppleIcon144x144Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ func staticImgCowyoAppleIcon152x152Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-152x152.png", size: 7402, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-152x152.png", size: 7402, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -451,7 +451,7 @@ func staticImgCowyoAppleIcon180x180Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-180x180.png", size: 9390, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-180x180.png", size: 9390, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ func staticImgCowyoAppleIcon57x57Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-57x57.png", size: 2792, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-57x57.png", size: 2792, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -491,7 +491,7 @@ func staticImgCowyoAppleIcon60x60Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-60x60.png", size: 2900, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-60x60.png", size: 2900, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -511,7 +511,7 @@ func staticImgCowyoAppleIcon72x72Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-72x72.png", size: 3317, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-72x72.png", size: 3317, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -531,7 +531,7 @@ func staticImgCowyoAppleIcon76x76Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-76x76.png", size: 3474, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-76x76.png", size: 3474, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ func staticImgCowyoAppleIconPrecomposedPng() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-precomposed.png", size: 8684, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon-precomposed.png", size: 8684, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ func staticImgCowyoAppleIconPng() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/apple-icon.png", size: 8684, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/apple-icon.png", size: 8684, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -591,7 +591,7 @@ func staticImgCowyoBrowserconfigXml() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/browserconfig.xml", size: 281, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/browserconfig.xml", size: 281, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -611,7 +611,7 @@ func staticImgCowyoFavicon16x16Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/favicon-16x16.png", size: 381, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/favicon-16x16.png", size: 381, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -631,7 +631,7 @@ func staticImgCowyoFavicon32x32Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/favicon-32x32.png", size: 1793, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/favicon-32x32.png", size: 1793, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -651,7 +651,7 @@ func staticImgCowyoFavicon96x96Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/favicon-96x96.png", size: 4296, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/favicon-96x96.png", size: 4296, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ func staticImgCowyoFaviconIco() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/favicon.ico", size: 1150, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/favicon.ico", size: 1150, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ func staticImgCowyoManifestJson() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/manifest.json", size: 720, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/manifest.json", size: 720, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -711,7 +711,7 @@ func staticImgCowyoMsIcon144x144Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-144x144.png", size: 6819, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -731,7 +731,7 @@ func staticImgCowyoMsIcon150x150Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-150x150.png", size: 7255, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-150x150.png", size: 7255, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -751,7 +751,7 @@ func staticImgCowyoMsIcon310x310Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-310x310.png", size: 22194, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-310x310.png", size: 22194, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -771,7 +771,7 @@ func staticImgCowyoMsIcon70x70Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-70x70.png", size: 3245, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/cowyo/ms-icon-70x70.png", size: 3245, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -791,7 +791,7 @@ func staticImgLogoPng() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/img/logo.png", size: 1962, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/img/logo.png", size: 1962, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -811,7 +811,7 @@ func staticJsCowyoJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/js/cowyo.js", size: 13588, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/js/cowyo.js", size: 13588, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ func staticJsDropzoneJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/js/dropzone.js", size: 120533, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/js/dropzone.js", size: 120533, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -851,7 +851,7 @@ func staticJsHighlightMinJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/js/highlight.min.js", size: 45164, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/js/highlight.min.js", size: 45164, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -871,7 +871,7 @@ func staticJsHighlightPackJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/js/highlight.pack.js", size: 45229, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/js/highlight.pack.js", size: 45229, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -891,7 +891,7 @@ func staticJsJquery183Js() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/js/jquery-1.8.3.js", size: 266057, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/js/jquery-1.8.3.js", size: 266057, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -911,7 +911,7 @@ func staticTextAdjectives() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/adjectives", size: 153332, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/adjectives", size: 153332, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -931,7 +931,7 @@ func staticTextAdjectivesOld() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/adjectives.old", size: 3316, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/adjectives.old", size: 3316, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -951,7 +951,7 @@ func staticTextAnimals() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/animals", size: 7533, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/animals", size: 7533, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -971,7 +971,7 @@ func staticTextAnimalsAll() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/animals.all", size: 47655, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/animals.all", size: 47655, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -991,7 +991,7 @@ func staticTextHowmanyPy() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/howmany.py", size: 639, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/howmany.py", size: 639, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ func staticTextRobotsTxt() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/robots.txt", size: 64, mode: os.FileMode(436), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/robots.txt", size: 64, mode: os.FileMode(436), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -1031,7 +1031,7 @@ func staticTextSitemapXml() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "static/text/sitemap.xml", size: 293, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "static/text/sitemap.xml", size: 293, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -1051,7 +1051,7 @@ func templatesIndexTmpl() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "templates/index.tmpl", size: 13524, mode: os.FileMode(509), modTime: time.Unix(1524397701, 0)}
|
info := bindataFileInfo{name: "templates/index.tmpl", size: 13524, mode: os.FileMode(509), modTime: time.Unix(1532209604, 0)}
|
||||||
a := &asset{bytes: bytes, info: info}
|
a := &asset{bytes: bytes, info: info}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@ -1108,53 +1108,53 @@ func AssetNames() []string {
|
|||||||
|
|
||||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||||
var _bindata = map[string]func() (*asset, error){
|
var _bindata = map[string]func() (*asset, error){
|
||||||
"static/css/base-min.css": staticCssBaseMinCss,
|
"static/css/base-min.css": staticCssBaseMinCss,
|
||||||
"static/css/default.css": staticCssDefaultCss,
|
"static/css/default.css": staticCssDefaultCss,
|
||||||
"static/css/dropzone.css": staticCssDropzoneCss,
|
"static/css/dropzone.css": staticCssDropzoneCss,
|
||||||
"static/css/github-markdown.css": staticCssGithubMarkdownCss,
|
"static/css/github-markdown.css": staticCssGithubMarkdownCss,
|
||||||
"static/css/highlight.css": staticCssHighlightCss,
|
"static/css/highlight.css": staticCssHighlightCss,
|
||||||
"static/css/menus-min.css": staticCssMenusMinCss,
|
"static/css/menus-min.css": staticCssMenusMinCss,
|
||||||
"static/img/cowyo/android-icon-144x144.png": staticImgCowyoAndroidIcon144x144Png,
|
"static/img/cowyo/android-icon-144x144.png": staticImgCowyoAndroidIcon144x144Png,
|
||||||
"static/img/cowyo/android-icon-192x192.png": staticImgCowyoAndroidIcon192x192Png,
|
"static/img/cowyo/android-icon-192x192.png": staticImgCowyoAndroidIcon192x192Png,
|
||||||
"static/img/cowyo/android-icon-36x36.png": staticImgCowyoAndroidIcon36x36Png,
|
"static/img/cowyo/android-icon-36x36.png": staticImgCowyoAndroidIcon36x36Png,
|
||||||
"static/img/cowyo/android-icon-48x48.png": staticImgCowyoAndroidIcon48x48Png,
|
"static/img/cowyo/android-icon-48x48.png": staticImgCowyoAndroidIcon48x48Png,
|
||||||
"static/img/cowyo/android-icon-72x72.png": staticImgCowyoAndroidIcon72x72Png,
|
"static/img/cowyo/android-icon-72x72.png": staticImgCowyoAndroidIcon72x72Png,
|
||||||
"static/img/cowyo/android-icon-96x96.png": staticImgCowyoAndroidIcon96x96Png,
|
"static/img/cowyo/android-icon-96x96.png": staticImgCowyoAndroidIcon96x96Png,
|
||||||
"static/img/cowyo/apple-icon-114x114.png": staticImgCowyoAppleIcon114x114Png,
|
"static/img/cowyo/apple-icon-114x114.png": staticImgCowyoAppleIcon114x114Png,
|
||||||
"static/img/cowyo/apple-icon-120x120.png": staticImgCowyoAppleIcon120x120Png,
|
"static/img/cowyo/apple-icon-120x120.png": staticImgCowyoAppleIcon120x120Png,
|
||||||
"static/img/cowyo/apple-icon-144x144.png": staticImgCowyoAppleIcon144x144Png,
|
"static/img/cowyo/apple-icon-144x144.png": staticImgCowyoAppleIcon144x144Png,
|
||||||
"static/img/cowyo/apple-icon-152x152.png": staticImgCowyoAppleIcon152x152Png,
|
"static/img/cowyo/apple-icon-152x152.png": staticImgCowyoAppleIcon152x152Png,
|
||||||
"static/img/cowyo/apple-icon-180x180.png": staticImgCowyoAppleIcon180x180Png,
|
"static/img/cowyo/apple-icon-180x180.png": staticImgCowyoAppleIcon180x180Png,
|
||||||
"static/img/cowyo/apple-icon-57x57.png": staticImgCowyoAppleIcon57x57Png,
|
"static/img/cowyo/apple-icon-57x57.png": staticImgCowyoAppleIcon57x57Png,
|
||||||
"static/img/cowyo/apple-icon-60x60.png": staticImgCowyoAppleIcon60x60Png,
|
"static/img/cowyo/apple-icon-60x60.png": staticImgCowyoAppleIcon60x60Png,
|
||||||
"static/img/cowyo/apple-icon-72x72.png": staticImgCowyoAppleIcon72x72Png,
|
"static/img/cowyo/apple-icon-72x72.png": staticImgCowyoAppleIcon72x72Png,
|
||||||
"static/img/cowyo/apple-icon-76x76.png": staticImgCowyoAppleIcon76x76Png,
|
"static/img/cowyo/apple-icon-76x76.png": staticImgCowyoAppleIcon76x76Png,
|
||||||
"static/img/cowyo/apple-icon-precomposed.png": staticImgCowyoAppleIconPrecomposedPng,
|
"static/img/cowyo/apple-icon-precomposed.png": staticImgCowyoAppleIconPrecomposedPng,
|
||||||
"static/img/cowyo/apple-icon.png": staticImgCowyoAppleIconPng,
|
"static/img/cowyo/apple-icon.png": staticImgCowyoAppleIconPng,
|
||||||
"static/img/cowyo/browserconfig.xml": staticImgCowyoBrowserconfigXml,
|
"static/img/cowyo/browserconfig.xml": staticImgCowyoBrowserconfigXml,
|
||||||
"static/img/cowyo/favicon-16x16.png": staticImgCowyoFavicon16x16Png,
|
"static/img/cowyo/favicon-16x16.png": staticImgCowyoFavicon16x16Png,
|
||||||
"static/img/cowyo/favicon-32x32.png": staticImgCowyoFavicon32x32Png,
|
"static/img/cowyo/favicon-32x32.png": staticImgCowyoFavicon32x32Png,
|
||||||
"static/img/cowyo/favicon-96x96.png": staticImgCowyoFavicon96x96Png,
|
"static/img/cowyo/favicon-96x96.png": staticImgCowyoFavicon96x96Png,
|
||||||
"static/img/cowyo/favicon.ico": staticImgCowyoFaviconIco,
|
"static/img/cowyo/favicon.ico": staticImgCowyoFaviconIco,
|
||||||
"static/img/cowyo/manifest.json": staticImgCowyoManifestJson,
|
"static/img/cowyo/manifest.json": staticImgCowyoManifestJson,
|
||||||
"static/img/cowyo/ms-icon-144x144.png": staticImgCowyoMsIcon144x144Png,
|
"static/img/cowyo/ms-icon-144x144.png": staticImgCowyoMsIcon144x144Png,
|
||||||
"static/img/cowyo/ms-icon-150x150.png": staticImgCowyoMsIcon150x150Png,
|
"static/img/cowyo/ms-icon-150x150.png": staticImgCowyoMsIcon150x150Png,
|
||||||
"static/img/cowyo/ms-icon-310x310.png": staticImgCowyoMsIcon310x310Png,
|
"static/img/cowyo/ms-icon-310x310.png": staticImgCowyoMsIcon310x310Png,
|
||||||
"static/img/cowyo/ms-icon-70x70.png": staticImgCowyoMsIcon70x70Png,
|
"static/img/cowyo/ms-icon-70x70.png": staticImgCowyoMsIcon70x70Png,
|
||||||
"static/img/logo.png": staticImgLogoPng,
|
"static/img/logo.png": staticImgLogoPng,
|
||||||
"static/js/cowyo.js": staticJsCowyoJs,
|
"static/js/cowyo.js": staticJsCowyoJs,
|
||||||
"static/js/dropzone.js": staticJsDropzoneJs,
|
"static/js/dropzone.js": staticJsDropzoneJs,
|
||||||
"static/js/highlight.min.js": staticJsHighlightMinJs,
|
"static/js/highlight.min.js": staticJsHighlightMinJs,
|
||||||
"static/js/highlight.pack.js": staticJsHighlightPackJs,
|
"static/js/highlight.pack.js": staticJsHighlightPackJs,
|
||||||
"static/js/jquery-1.8.3.js": staticJsJquery183Js,
|
"static/js/jquery-1.8.3.js": staticJsJquery183Js,
|
||||||
"static/text/adjectives": staticTextAdjectives,
|
"static/text/adjectives": staticTextAdjectives,
|
||||||
"static/text/adjectives.old": staticTextAdjectivesOld,
|
"static/text/adjectives.old": staticTextAdjectivesOld,
|
||||||
"static/text/animals": staticTextAnimals,
|
"static/text/animals": staticTextAnimals,
|
||||||
"static/text/animals.all": staticTextAnimalsAll,
|
"static/text/animals.all": staticTextAnimalsAll,
|
||||||
"static/text/howmany.py": staticTextHowmanyPy,
|
"static/text/howmany.py": staticTextHowmanyPy,
|
||||||
"static/text/robots.txt": staticTextRobotsTxt,
|
"static/text/robots.txt": staticTextRobotsTxt,
|
||||||
"static/text/sitemap.xml": staticTextSitemapXml,
|
"static/text/sitemap.xml": staticTextSitemapXml,
|
||||||
"templates/index.tmpl": templatesIndexTmpl,
|
"templates/index.tmpl": templatesIndexTmpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssetDir returns the file names below a certain
|
// AssetDir returns the file names below a certain
|
||||||
@ -1196,64 +1196,63 @@ type bintree struct {
|
|||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
|
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"static": &bintree{nil, map[string]*bintree{
|
"static": &bintree{nil, map[string]*bintree{
|
||||||
"css": &bintree{nil, map[string]*bintree{
|
"css": &bintree{nil, map[string]*bintree{
|
||||||
"base-min.css": &bintree{staticCssBaseMinCss, map[string]*bintree{}},
|
"base-min.css": &bintree{staticCssBaseMinCss, map[string]*bintree{}},
|
||||||
"default.css": &bintree{staticCssDefaultCss, map[string]*bintree{}},
|
"default.css": &bintree{staticCssDefaultCss, map[string]*bintree{}},
|
||||||
"dropzone.css": &bintree{staticCssDropzoneCss, map[string]*bintree{}},
|
"dropzone.css": &bintree{staticCssDropzoneCss, map[string]*bintree{}},
|
||||||
"github-markdown.css": &bintree{staticCssGithubMarkdownCss, map[string]*bintree{}},
|
"github-markdown.css": &bintree{staticCssGithubMarkdownCss, map[string]*bintree{}},
|
||||||
"highlight.css": &bintree{staticCssHighlightCss, map[string]*bintree{}},
|
"highlight.css": &bintree{staticCssHighlightCss, map[string]*bintree{}},
|
||||||
"menus-min.css": &bintree{staticCssMenusMinCss, map[string]*bintree{}},
|
"menus-min.css": &bintree{staticCssMenusMinCss, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
"img": &bintree{nil, map[string]*bintree{
|
"img": &bintree{nil, map[string]*bintree{
|
||||||
"cowyo": &bintree{nil, map[string]*bintree{
|
"cowyo": &bintree{nil, map[string]*bintree{
|
||||||
"android-icon-144x144.png": &bintree{staticImgCowyoAndroidIcon144x144Png, map[string]*bintree{}},
|
"android-icon-144x144.png": &bintree{staticImgCowyoAndroidIcon144x144Png, map[string]*bintree{}},
|
||||||
"android-icon-192x192.png": &bintree{staticImgCowyoAndroidIcon192x192Png, map[string]*bintree{}},
|
"android-icon-192x192.png": &bintree{staticImgCowyoAndroidIcon192x192Png, map[string]*bintree{}},
|
||||||
"android-icon-36x36.png": &bintree{staticImgCowyoAndroidIcon36x36Png, map[string]*bintree{}},
|
"android-icon-36x36.png": &bintree{staticImgCowyoAndroidIcon36x36Png, map[string]*bintree{}},
|
||||||
"android-icon-48x48.png": &bintree{staticImgCowyoAndroidIcon48x48Png, map[string]*bintree{}},
|
"android-icon-48x48.png": &bintree{staticImgCowyoAndroidIcon48x48Png, map[string]*bintree{}},
|
||||||
"android-icon-72x72.png": &bintree{staticImgCowyoAndroidIcon72x72Png, map[string]*bintree{}},
|
"android-icon-72x72.png": &bintree{staticImgCowyoAndroidIcon72x72Png, map[string]*bintree{}},
|
||||||
"android-icon-96x96.png": &bintree{staticImgCowyoAndroidIcon96x96Png, map[string]*bintree{}},
|
"android-icon-96x96.png": &bintree{staticImgCowyoAndroidIcon96x96Png, map[string]*bintree{}},
|
||||||
"apple-icon-114x114.png": &bintree{staticImgCowyoAppleIcon114x114Png, map[string]*bintree{}},
|
"apple-icon-114x114.png": &bintree{staticImgCowyoAppleIcon114x114Png, map[string]*bintree{}},
|
||||||
"apple-icon-120x120.png": &bintree{staticImgCowyoAppleIcon120x120Png, map[string]*bintree{}},
|
"apple-icon-120x120.png": &bintree{staticImgCowyoAppleIcon120x120Png, map[string]*bintree{}},
|
||||||
"apple-icon-144x144.png": &bintree{staticImgCowyoAppleIcon144x144Png, map[string]*bintree{}},
|
"apple-icon-144x144.png": &bintree{staticImgCowyoAppleIcon144x144Png, map[string]*bintree{}},
|
||||||
"apple-icon-152x152.png": &bintree{staticImgCowyoAppleIcon152x152Png, map[string]*bintree{}},
|
"apple-icon-152x152.png": &bintree{staticImgCowyoAppleIcon152x152Png, map[string]*bintree{}},
|
||||||
"apple-icon-180x180.png": &bintree{staticImgCowyoAppleIcon180x180Png, map[string]*bintree{}},
|
"apple-icon-180x180.png": &bintree{staticImgCowyoAppleIcon180x180Png, map[string]*bintree{}},
|
||||||
"apple-icon-57x57.png": &bintree{staticImgCowyoAppleIcon57x57Png, map[string]*bintree{}},
|
"apple-icon-57x57.png": &bintree{staticImgCowyoAppleIcon57x57Png, map[string]*bintree{}},
|
||||||
"apple-icon-60x60.png": &bintree{staticImgCowyoAppleIcon60x60Png, map[string]*bintree{}},
|
"apple-icon-60x60.png": &bintree{staticImgCowyoAppleIcon60x60Png, map[string]*bintree{}},
|
||||||
"apple-icon-72x72.png": &bintree{staticImgCowyoAppleIcon72x72Png, map[string]*bintree{}},
|
"apple-icon-72x72.png": &bintree{staticImgCowyoAppleIcon72x72Png, map[string]*bintree{}},
|
||||||
"apple-icon-76x76.png": &bintree{staticImgCowyoAppleIcon76x76Png, map[string]*bintree{}},
|
"apple-icon-76x76.png": &bintree{staticImgCowyoAppleIcon76x76Png, map[string]*bintree{}},
|
||||||
"apple-icon-precomposed.png": &bintree{staticImgCowyoAppleIconPrecomposedPng, map[string]*bintree{}},
|
"apple-icon-precomposed.png": &bintree{staticImgCowyoAppleIconPrecomposedPng, map[string]*bintree{}},
|
||||||
"apple-icon.png": &bintree{staticImgCowyoAppleIconPng, map[string]*bintree{}},
|
"apple-icon.png": &bintree{staticImgCowyoAppleIconPng, map[string]*bintree{}},
|
||||||
"browserconfig.xml": &bintree{staticImgCowyoBrowserconfigXml, map[string]*bintree{}},
|
"browserconfig.xml": &bintree{staticImgCowyoBrowserconfigXml, map[string]*bintree{}},
|
||||||
"favicon-16x16.png": &bintree{staticImgCowyoFavicon16x16Png, map[string]*bintree{}},
|
"favicon-16x16.png": &bintree{staticImgCowyoFavicon16x16Png, map[string]*bintree{}},
|
||||||
"favicon-32x32.png": &bintree{staticImgCowyoFavicon32x32Png, map[string]*bintree{}},
|
"favicon-32x32.png": &bintree{staticImgCowyoFavicon32x32Png, map[string]*bintree{}},
|
||||||
"favicon-96x96.png": &bintree{staticImgCowyoFavicon96x96Png, map[string]*bintree{}},
|
"favicon-96x96.png": &bintree{staticImgCowyoFavicon96x96Png, map[string]*bintree{}},
|
||||||
"favicon.ico": &bintree{staticImgCowyoFaviconIco, map[string]*bintree{}},
|
"favicon.ico": &bintree{staticImgCowyoFaviconIco, map[string]*bintree{}},
|
||||||
"manifest.json": &bintree{staticImgCowyoManifestJson, map[string]*bintree{}},
|
"manifest.json": &bintree{staticImgCowyoManifestJson, map[string]*bintree{}},
|
||||||
"ms-icon-144x144.png": &bintree{staticImgCowyoMsIcon144x144Png, map[string]*bintree{}},
|
"ms-icon-144x144.png": &bintree{staticImgCowyoMsIcon144x144Png, map[string]*bintree{}},
|
||||||
"ms-icon-150x150.png": &bintree{staticImgCowyoMsIcon150x150Png, map[string]*bintree{}},
|
"ms-icon-150x150.png": &bintree{staticImgCowyoMsIcon150x150Png, map[string]*bintree{}},
|
||||||
"ms-icon-310x310.png": &bintree{staticImgCowyoMsIcon310x310Png, map[string]*bintree{}},
|
"ms-icon-310x310.png": &bintree{staticImgCowyoMsIcon310x310Png, map[string]*bintree{}},
|
||||||
"ms-icon-70x70.png": &bintree{staticImgCowyoMsIcon70x70Png, map[string]*bintree{}},
|
"ms-icon-70x70.png": &bintree{staticImgCowyoMsIcon70x70Png, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
"logo.png": &bintree{staticImgLogoPng, map[string]*bintree{}},
|
"logo.png": &bintree{staticImgLogoPng, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
"js": &bintree{nil, map[string]*bintree{
|
"js": &bintree{nil, map[string]*bintree{
|
||||||
"cowyo.js": &bintree{staticJsCowyoJs, map[string]*bintree{}},
|
"cowyo.js": &bintree{staticJsCowyoJs, map[string]*bintree{}},
|
||||||
"dropzone.js": &bintree{staticJsDropzoneJs, map[string]*bintree{}},
|
"dropzone.js": &bintree{staticJsDropzoneJs, map[string]*bintree{}},
|
||||||
"highlight.min.js": &bintree{staticJsHighlightMinJs, map[string]*bintree{}},
|
"highlight.min.js": &bintree{staticJsHighlightMinJs, map[string]*bintree{}},
|
||||||
"highlight.pack.js": &bintree{staticJsHighlightPackJs, map[string]*bintree{}},
|
"highlight.pack.js": &bintree{staticJsHighlightPackJs, map[string]*bintree{}},
|
||||||
"jquery-1.8.3.js": &bintree{staticJsJquery183Js, map[string]*bintree{}},
|
"jquery-1.8.3.js": &bintree{staticJsJquery183Js, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
"text": &bintree{nil, map[string]*bintree{
|
"text": &bintree{nil, map[string]*bintree{
|
||||||
"adjectives": &bintree{staticTextAdjectives, map[string]*bintree{}},
|
"adjectives": &bintree{staticTextAdjectives, map[string]*bintree{}},
|
||||||
"adjectives.old": &bintree{staticTextAdjectivesOld, map[string]*bintree{}},
|
"adjectives.old": &bintree{staticTextAdjectivesOld, map[string]*bintree{}},
|
||||||
"animals": &bintree{staticTextAnimals, map[string]*bintree{}},
|
"animals": &bintree{staticTextAnimals, map[string]*bintree{}},
|
||||||
"animals.all": &bintree{staticTextAnimalsAll, map[string]*bintree{}},
|
"animals.all": &bintree{staticTextAnimalsAll, map[string]*bintree{}},
|
||||||
"howmany.py": &bintree{staticTextHowmanyPy, map[string]*bintree{}},
|
"howmany.py": &bintree{staticTextHowmanyPy, map[string]*bintree{}},
|
||||||
"robots.txt": &bintree{staticTextRobotsTxt, map[string]*bintree{}},
|
"robots.txt": &bintree{staticTextRobotsTxt, map[string]*bintree{}},
|
||||||
"sitemap.xml": &bintree{staticTextSitemapXml, map[string]*bintree{}},
|
"sitemap.xml": &bintree{staticTextSitemapXml, map[string]*bintree{}},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
"templates": &bintree{nil, map[string]*bintree{
|
"templates": &bintree{nil, map[string]*bintree{
|
||||||
@ -1307,3 +1306,4 @@ func _filePath(dir, name string) string {
|
|||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
vendor/github.com/gin-gonic/gin/.github/ISSUE_TEMPLATE.md
generated
vendored
Normal file
13
vendor/github.com/gin-gonic/gin/.github/ISSUE_TEMPLATE.md
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
- With issues:
|
||||||
|
- Use the search tool before opening a new issue.
|
||||||
|
- Please provide source code and commit sha if you found a bug.
|
||||||
|
- Review existing issues and provide feedback or react to them.
|
||||||
|
|
||||||
|
- gin version (or commit ref):
|
||||||
|
- git version:
|
||||||
|
- operating system:
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
7
vendor/github.com/gin-gonic/gin/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
7
vendor/github.com/gin-gonic/gin/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- With pull requests:
|
||||||
|
- Open your pull request against `master`
|
||||||
|
- Your pull request should have no more than two commits, if not you should squash them.
|
||||||
|
- It should pass all tests in the available continuous integrations systems such as TravisCI.
|
||||||
|
- You should add/modify tests to cover your proposed code changes.
|
||||||
|
- If your pull request contains a new feature, please document it on the README.
|
||||||
|
|
1
vendor/github.com/gin-gonic/gin/.gitignore
generated
vendored
1
vendor/github.com/gin-gonic/gin/.gitignore
generated
vendored
@ -2,3 +2,4 @@ vendor/*
|
|||||||
!vendor/vendor.json
|
!vendor/vendor.json
|
||||||
coverage.out
|
coverage.out
|
||||||
count.out
|
count.out
|
||||||
|
test
|
||||||
|
6
vendor/github.com/gin-gonic/gin/.travis.yml
generated
vendored
6
vendor/github.com/gin-gonic/gin/.travis.yml
generated
vendored
@ -4,14 +4,18 @@ go:
|
|||||||
- 1.6.x
|
- 1.6.x
|
||||||
- 1.7.x
|
- 1.7.x
|
||||||
- 1.8.x
|
- 1.8.x
|
||||||
|
- 1.9.x
|
||||||
|
- 1.10.x
|
||||||
- master
|
- master
|
||||||
|
|
||||||
git:
|
git:
|
||||||
depth: 3
|
depth: 10
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- make install
|
- make install
|
||||||
|
|
||||||
|
go_import_path: github.com/gin-gonic/gin
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make vet
|
- make vet
|
||||||
- make fmt-check
|
- make fmt-check
|
||||||
|
6
vendor/github.com/gin-gonic/gin/AUTHORS.md
generated
vendored
6
vendor/github.com/gin-gonic/gin/AUTHORS.md
generated
vendored
@ -1,8 +1,12 @@
|
|||||||
List of all the awesome people working to make Gin the best Web Framework in Go.
|
List of all the awesome people working to make Gin the best Web Framework in Go.
|
||||||
|
|
||||||
|
## gin 1.x series authors
|
||||||
|
|
||||||
|
**Gin Core Team:** Bo-Yi Wu (@appleboy), 田欧 (@thinkerou), Javier Provecho (@javierprovecho)
|
||||||
|
|
||||||
## gin 0.x series authors
|
## gin 0.x series authors
|
||||||
|
|
||||||
**Maintainer:** Manu Martinez-Almeida (@manucorporat), Javier Provecho (@javierprovecho)
|
**Maintainers:** Manu Martinez-Almeida (@manucorporat), Javier Provecho (@javierprovecho)
|
||||||
|
|
||||||
People and companies, who have contributed, in alphabetical order.
|
People and companies, who have contributed, in alphabetical order.
|
||||||
|
|
||||||
|
896
vendor/github.com/gin-gonic/gin/BENCHMARKS.md
generated
vendored
896
vendor/github.com/gin-gonic/gin/BENCHMARKS.md
generated
vendored
@ -1,298 +1,604 @@
|
|||||||
**Machine:** intel i7 ivy bridge quad-core. 8GB RAM.
|
|
||||||
**Date:** June 4th, 2015
|
## Benchmark System
|
||||||
[https://github.com/gin-gonic/go-http-routing-benchmark](https://github.com/gin-gonic/go-http-routing-benchmark)
|
|
||||||
|
**VM HOST:** DigitalOcean
|
||||||
|
**Machine:** 4 CPU, 8 GB RAM. Ubuntu 16.04.2 x64
|
||||||
|
**Date:** July 19th, 2017
|
||||||
|
**Go Version:** 1.8.3 linux/amd64
|
||||||
|
**Source:** [Go HTTP Router Benchmark](https://github.com/julienschmidt/go-http-routing-benchmark)
|
||||||
|
|
||||||
|
## Static Routes: 157
|
||||||
|
|
||||||
```
|
```
|
||||||
BenchmarkAce_Param 5000000 372 ns/op 32 B/op 1 allocs/op
|
Gin: 30512 Bytes
|
||||||
BenchmarkBear_Param 1000000 1165 ns/op 424 B/op 5 allocs/op
|
|
||||||
BenchmarkBeego_Param 1000000 2440 ns/op 720 B/op 10 allocs/op
|
HttpServeMux: 17344 Bytes
|
||||||
BenchmarkBone_Param 1000000 1067 ns/op 384 B/op 3 allocs/op
|
Ace: 30080 Bytes
|
||||||
BenchmarkDenco_Param 5000000 240 ns/op 32 B/op 1 allocs/op
|
Bear: 30472 Bytes
|
||||||
BenchmarkEcho_Param 10000000 130 ns/op 0 B/op 0 allocs/op
|
Beego: 96408 Bytes
|
||||||
BenchmarkGin_Param 10000000 133 ns/op 0 B/op 0 allocs/op
|
Bone: 37904 Bytes
|
||||||
BenchmarkGocraftWeb_Param 1000000 1826 ns/op 656 B/op 9 allocs/op
|
Denco: 10464 Bytes
|
||||||
BenchmarkGoji_Param 2000000 957 ns/op 336 B/op 2 allocs/op
|
Echo: 73680 Bytes
|
||||||
BenchmarkGoJsonRest_Param 1000000 2021 ns/op 657 B/op 14 allocs/op
|
GocraftWeb: 55720 Bytes
|
||||||
BenchmarkGoRestful_Param 200000 8825 ns/op 2496 B/op 31 allocs/op
|
Goji: 27200 Bytes
|
||||||
BenchmarkGorillaMux_Param 500000 3340 ns/op 784 B/op 9 allocs/op
|
Gojiv2: 104464 Bytes
|
||||||
BenchmarkHttpRouter_Param 10000000 152 ns/op 32 B/op 1 allocs/op
|
GoJsonRest: 136472 Bytes
|
||||||
BenchmarkHttpTreeMux_Param 2000000 717 ns/op 336 B/op 2 allocs/op
|
GoRestful: 914904 Bytes
|
||||||
BenchmarkKocha_Param 3000000 423 ns/op 56 B/op 3 allocs/op
|
GorillaMux: 675568 Bytes
|
||||||
BenchmarkMacaron_Param 1000000 3410 ns/op 1104 B/op 11 allocs/op
|
HttpRouter: 21128 Bytes
|
||||||
BenchmarkMartini_Param 200000 7101 ns/op 1152 B/op 12 allocs/op
|
HttpTreeMux: 73448 Bytes
|
||||||
BenchmarkPat_Param 1000000 2040 ns/op 656 B/op 14 allocs/op
|
Kocha: 115072 Bytes
|
||||||
BenchmarkPossum_Param 1000000 2048 ns/op 624 B/op 7 allocs/op
|
LARS: 30120 Bytes
|
||||||
BenchmarkR2router_Param 1000000 1144 ns/op 432 B/op 6 allocs/op
|
Macaron: 37984 Bytes
|
||||||
BenchmarkRevel_Param 200000 6725 ns/op 1672 B/op 28 allocs/op
|
Martini: 310832 Bytes
|
||||||
BenchmarkRivet_Param 1000000 1121 ns/op 464 B/op 5 allocs/op
|
Pat: 20464 Bytes
|
||||||
BenchmarkTango_Param 1000000 1479 ns/op 256 B/op 10 allocs/op
|
Possum: 91328 Bytes
|
||||||
BenchmarkTigerTonic_Param 1000000 3393 ns/op 992 B/op 19 allocs/op
|
R2router: 23712 Bytes
|
||||||
BenchmarkTraffic_Param 300000 5525 ns/op 1984 B/op 23 allocs/op
|
Rivet: 23880 Bytes
|
||||||
BenchmarkVulcan_Param 2000000 924 ns/op 98 B/op 3 allocs/op
|
Tango: 28008 Bytes
|
||||||
BenchmarkZeus_Param 1000000 1084 ns/op 368 B/op 3 allocs/op
|
TigerTonic: 80368 Bytes
|
||||||
BenchmarkAce_Param5 3000000 614 ns/op 160 B/op 1 allocs/op
|
Traffic: 626480 Bytes
|
||||||
BenchmarkBear_Param5 1000000 1617 ns/op 469 B/op 5 allocs/op
|
Vulcan: 369064 Bytes
|
||||||
BenchmarkBeego_Param5 1000000 3373 ns/op 992 B/op 13 allocs/op
|
```
|
||||||
BenchmarkBone_Param5 1000000 1478 ns/op 432 B/op 3 allocs/op
|
|
||||||
BenchmarkDenco_Param5 3000000 570 ns/op 160 B/op 1 allocs/op
|
## GithubAPI Routes: 203
|
||||||
BenchmarkEcho_Param5 5000000 256 ns/op 0 B/op 0 allocs/op
|
|
||||||
BenchmarkGin_Param5 10000000 222 ns/op 0 B/op 0 allocs/op
|
```
|
||||||
BenchmarkGocraftWeb_Param5 1000000 2789 ns/op 928 B/op 12 allocs/op
|
Gin: 52672 Bytes
|
||||||
BenchmarkGoji_Param5 1000000 1287 ns/op 336 B/op 2 allocs/op
|
|
||||||
BenchmarkGoJsonRest_Param5 1000000 3670 ns/op 1105 B/op 17 allocs/op
|
Ace: 48992 Bytes
|
||||||
BenchmarkGoRestful_Param5 200000 10756 ns/op 2672 B/op 31 allocs/op
|
Bear: 161592 Bytes
|
||||||
BenchmarkGorillaMux_Param5 300000 5543 ns/op 912 B/op 9 allocs/op
|
Beego: 147992 Bytes
|
||||||
BenchmarkHttpRouter_Param5 5000000 403 ns/op 160 B/op 1 allocs/op
|
Bone: 97728 Bytes
|
||||||
BenchmarkHttpTreeMux_Param5 1000000 1089 ns/op 336 B/op 2 allocs/op
|
Denco: 36440 Bytes
|
||||||
BenchmarkKocha_Param5 1000000 1682 ns/op 440 B/op 10 allocs/op
|
Echo: 95672 Bytes
|
||||||
BenchmarkMacaron_Param5 300000 4596 ns/op 1376 B/op 14 allocs/op
|
GocraftWeb: 95640 Bytes
|
||||||
BenchmarkMartini_Param5 100000 15703 ns/op 1280 B/op 12 allocs/op
|
Goji: 86088 Bytes
|
||||||
BenchmarkPat_Param5 300000 5320 ns/op 1008 B/op 42 allocs/op
|
Gojiv2: 144392 Bytes
|
||||||
BenchmarkPossum_Param5 1000000 2155 ns/op 624 B/op 7 allocs/op
|
GoJsonRest: 134648 Bytes
|
||||||
BenchmarkR2router_Param5 1000000 1559 ns/op 432 B/op 6 allocs/op
|
GoRestful: 1410760 Bytes
|
||||||
BenchmarkRevel_Param5 200000 8184 ns/op 2024 B/op 35 allocs/op
|
GorillaMux: 1509488 Bytes
|
||||||
BenchmarkRivet_Param5 1000000 1914 ns/op 528 B/op 9 allocs/op
|
HttpRouter: 37464 Bytes
|
||||||
BenchmarkTango_Param5 1000000 3280 ns/op 944 B/op 18 allocs/op
|
HttpTreeMux: 78800 Bytes
|
||||||
BenchmarkTigerTonic_Param5 200000 11638 ns/op 2519 B/op 53 allocs/op
|
Kocha: 785408 Bytes
|
||||||
BenchmarkTraffic_Param5 200000 8941 ns/op 2280 B/op 31 allocs/op
|
LARS: 49032 Bytes
|
||||||
BenchmarkVulcan_Param5 1000000 1279 ns/op 98 B/op 3 allocs/op
|
Macaron: 132712 Bytes
|
||||||
BenchmarkZeus_Param5 1000000 1574 ns/op 416 B/op 3 allocs/op
|
Martini: 564352 Bytes
|
||||||
BenchmarkAce_Param20 1000000 1528 ns/op 640 B/op 1 allocs/op
|
Pat: 21200 Bytes
|
||||||
BenchmarkBear_Param20 300000 4906 ns/op 1633 B/op 5 allocs/op
|
Possum: 83888 Bytes
|
||||||
BenchmarkBeego_Param20 200000 10529 ns/op 3868 B/op 17 allocs/op
|
R2router: 47104 Bytes
|
||||||
BenchmarkBone_Param20 300000 7362 ns/op 2539 B/op 5 allocs/op
|
Rivet: 42840 Bytes
|
||||||
BenchmarkDenco_Param20 1000000 1884 ns/op 640 B/op 1 allocs/op
|
Tango: 54584 Bytes
|
||||||
BenchmarkEcho_Param20 2000000 689 ns/op 0 B/op 0 allocs/op
|
TigerTonic: 96384 Bytes
|
||||||
BenchmarkGin_Param20 3000000 545 ns/op 0 B/op 0 allocs/op
|
Traffic: 1061920 Bytes
|
||||||
BenchmarkGocraftWeb_Param20 200000 9437 ns/op 3804 B/op 16 allocs/op
|
Vulcan: 465296 Bytes
|
||||||
BenchmarkGoji_Param20 500000 3987 ns/op 1246 B/op 2 allocs/op
|
```
|
||||||
BenchmarkGoJsonRest_Param20 100000 12799 ns/op 4492 B/op 21 allocs/op
|
|
||||||
BenchmarkGoRestful_Param20 100000 19451 ns/op 5244 B/op 33 allocs/op
|
## GPlusAPI Routes: 13
|
||||||
BenchmarkGorillaMux_Param20 100000 12456 ns/op 3275 B/op 11 allocs/op
|
|
||||||
BenchmarkHttpRouter_Param20 1000000 1333 ns/op 640 B/op 1 allocs/op
|
```
|
||||||
BenchmarkHttpTreeMux_Param20 300000 6490 ns/op 2187 B/op 4 allocs/op
|
Gin: 3968 Bytes
|
||||||
BenchmarkKocha_Param20 300000 5335 ns/op 1808 B/op 27 allocs/op
|
|
||||||
BenchmarkMacaron_Param20 200000 11325 ns/op 4252 B/op 18 allocs/op
|
Ace: 3600 Bytes
|
||||||
BenchmarkMartini_Param20 20000 64419 ns/op 3644 B/op 14 allocs/op
|
Bear: 7112 Bytes
|
||||||
BenchmarkPat_Param20 50000 24672 ns/op 4888 B/op 151 allocs/op
|
Beego: 10048 Bytes
|
||||||
BenchmarkPossum_Param20 1000000 2085 ns/op 624 B/op 7 allocs/op
|
Bone: 6480 Bytes
|
||||||
BenchmarkR2router_Param20 300000 6809 ns/op 2283 B/op 8 allocs/op
|
Denco: 3256 Bytes
|
||||||
BenchmarkRevel_Param20 100000 16600 ns/op 5551 B/op 54 allocs/op
|
Echo: 9000 Bytes
|
||||||
BenchmarkRivet_Param20 200000 8428 ns/op 2620 B/op 26 allocs/op
|
GocraftWeb: 7496 Bytes
|
||||||
BenchmarkTango_Param20 100000 16302 ns/op 8224 B/op 48 allocs/op
|
Goji: 2912 Bytes
|
||||||
BenchmarkTigerTonic_Param20 30000 46828 ns/op 10538 B/op 178 allocs/op
|
Gojiv2: 7376 Bytes
|
||||||
BenchmarkTraffic_Param20 50000 28871 ns/op 7998 B/op 66 allocs/op
|
GoJsonRest: 11544 Bytes
|
||||||
BenchmarkVulcan_Param20 1000000 2267 ns/op 98 B/op 3 allocs/op
|
GoRestful: 88776 Bytes
|
||||||
BenchmarkZeus_Param20 300000 6828 ns/op 2507 B/op 5 allocs/op
|
GorillaMux: 71488 Bytes
|
||||||
BenchmarkAce_ParamWrite 3000000 502 ns/op 40 B/op 2 allocs/op
|
HttpRouter: 2712 Bytes
|
||||||
BenchmarkBear_ParamWrite 1000000 1303 ns/op 424 B/op 5 allocs/op
|
HttpTreeMux: 7440 Bytes
|
||||||
BenchmarkBeego_ParamWrite 1000000 2489 ns/op 728 B/op 11 allocs/op
|
Kocha: 128880 Bytes
|
||||||
BenchmarkBone_ParamWrite 1000000 1181 ns/op 384 B/op 3 allocs/op
|
LARS: 3640 Bytes
|
||||||
BenchmarkDenco_ParamWrite 5000000 315 ns/op 32 B/op 1 allocs/op
|
Macaron: 8656 Bytes
|
||||||
BenchmarkEcho_ParamWrite 10000000 237 ns/op 8 B/op 1 allocs/op
|
Martini: 23936 Bytes
|
||||||
BenchmarkGin_ParamWrite 5000000 336 ns/op 0 B/op 0 allocs/op
|
Pat: 1856 Bytes
|
||||||
BenchmarkGocraftWeb_ParamWrite 1000000 2079 ns/op 664 B/op 10 allocs/op
|
Possum: 7248 Bytes
|
||||||
BenchmarkGoji_ParamWrite 1000000 1092 ns/op 336 B/op 2 allocs/op
|
R2router: 3928 Bytes
|
||||||
BenchmarkGoJsonRest_ParamWrite 1000000 3329 ns/op 1136 B/op 19 allocs/op
|
Rivet: 3064 Bytes
|
||||||
BenchmarkGoRestful_ParamWrite 200000 9273 ns/op 2504 B/op 32 allocs/op
|
Tango: 4912 Bytes
|
||||||
BenchmarkGorillaMux_ParamWrite 500000 3919 ns/op 792 B/op 10 allocs/op
|
TigerTonic: 9408 Bytes
|
||||||
BenchmarkHttpRouter_ParamWrite 10000000 223 ns/op 32 B/op 1 allocs/op
|
Traffic: 49472 Bytes
|
||||||
BenchmarkHttpTreeMux_ParamWrite 2000000 788 ns/op 336 B/op 2 allocs/op
|
Vulcan: 25496 Bytes
|
||||||
BenchmarkKocha_ParamWrite 3000000 549 ns/op 56 B/op 3 allocs/op
|
```
|
||||||
BenchmarkMacaron_ParamWrite 500000 4558 ns/op 1216 B/op 16 allocs/op
|
|
||||||
BenchmarkMartini_ParamWrite 200000 8850 ns/op 1256 B/op 16 allocs/op
|
## ParseAPI Routes: 26
|
||||||
BenchmarkPat_ParamWrite 500000 3679 ns/op 1088 B/op 19 allocs/op
|
|
||||||
BenchmarkPossum_ParamWrite 1000000 2114 ns/op 624 B/op 7 allocs/op
|
```
|
||||||
BenchmarkR2router_ParamWrite 1000000 1320 ns/op 432 B/op 6 allocs/op
|
Gin: 6928 Bytes
|
||||||
BenchmarkRevel_ParamWrite 200000 8048 ns/op 2128 B/op 33 allocs/op
|
|
||||||
BenchmarkRivet_ParamWrite 1000000 1393 ns/op 472 B/op 6 allocs/op
|
Ace: 6592 Bytes
|
||||||
BenchmarkTango_ParamWrite 2000000 819 ns/op 136 B/op 5 allocs/op
|
Bear: 12320 Bytes
|
||||||
BenchmarkTigerTonic_ParamWrite 300000 5860 ns/op 1440 B/op 25 allocs/op
|
Beego: 18960 Bytes
|
||||||
BenchmarkTraffic_ParamWrite 200000 7429 ns/op 2400 B/op 27 allocs/op
|
Bone: 11024 Bytes
|
||||||
BenchmarkVulcan_ParamWrite 2000000 972 ns/op 98 B/op 3 allocs/op
|
Denco: 4184 Bytes
|
||||||
BenchmarkZeus_ParamWrite 1000000 1226 ns/op 368 B/op 3 allocs/op
|
Echo: 11168 Bytes
|
||||||
BenchmarkAce_GithubStatic 5000000 294 ns/op 0 B/op 0 allocs/op
|
GocraftWeb: 12800 Bytes
|
||||||
BenchmarkBear_GithubStatic 3000000 575 ns/op 88 B/op 3 allocs/op
|
Goji: 5232 Bytes
|
||||||
BenchmarkBeego_GithubStatic 1000000 1561 ns/op 368 B/op 7 allocs/op
|
Gojiv2: 14464 Bytes
|
||||||
BenchmarkBone_GithubStatic 200000 12301 ns/op 2880 B/op 60 allocs/op
|
GoJsonRest: 14216 Bytes
|
||||||
BenchmarkDenco_GithubStatic 20000000 74.6 ns/op 0 B/op 0 allocs/op
|
GoRestful: 127368 Bytes
|
||||||
BenchmarkEcho_GithubStatic 10000000 176 ns/op 0 B/op 0 allocs/op
|
GorillaMux: 123016 Bytes
|
||||||
BenchmarkGin_GithubStatic 10000000 159 ns/op 0 B/op 0 allocs/op
|
HttpRouter: 4976 Bytes
|
||||||
BenchmarkGocraftWeb_GithubStatic 1000000 1116 ns/op 304 B/op 6 allocs/op
|
HttpTreeMux: 7848 Bytes
|
||||||
BenchmarkGoji_GithubStatic 5000000 413 ns/op 0 B/op 0 allocs/op
|
Kocha: 181712 Bytes
|
||||||
BenchmarkGoRestful_GithubStatic 30000 55200 ns/op 3520 B/op 36 allocs/op
|
LARS: 6632 Bytes
|
||||||
BenchmarkGoJsonRest_GithubStatic 1000000 1504 ns/op 337 B/op 12 allocs/op
|
Macaron: 13648 Bytes
|
||||||
BenchmarkGorillaMux_GithubStatic 100000 23620 ns/op 464 B/op 8 allocs/op
|
Martini: 45952 Bytes
|
||||||
BenchmarkHttpRouter_GithubStatic 20000000 78.3 ns/op 0 B/op 0 allocs/op
|
Pat: 2560 Bytes
|
||||||
BenchmarkHttpTreeMux_GithubStatic 20000000 84.9 ns/op 0 B/op 0 allocs/op
|
Possum: 9200 Bytes
|
||||||
BenchmarkKocha_GithubStatic 20000000 111 ns/op 0 B/op 0 allocs/op
|
R2router: 7056 Bytes
|
||||||
BenchmarkMacaron_GithubStatic 1000000 2686 ns/op 752 B/op 8 allocs/op
|
Rivet: 5680 Bytes
|
||||||
BenchmarkMartini_GithubStatic 100000 22244 ns/op 832 B/op 11 allocs/op
|
Tango: 8664 Bytes
|
||||||
BenchmarkPat_GithubStatic 100000 13278 ns/op 3648 B/op 76 allocs/op
|
TigerTonic: 9840 Bytes
|
||||||
BenchmarkPossum_GithubStatic 1000000 1429 ns/op 480 B/op 4 allocs/op
|
Traffic: 93480 Bytes
|
||||||
BenchmarkR2router_GithubStatic 2000000 726 ns/op 144 B/op 5 allocs/op
|
Vulcan: 44504 Bytes
|
||||||
BenchmarkRevel_GithubStatic 300000 6271 ns/op 1288 B/op 25 allocs/op
|
```
|
||||||
BenchmarkRivet_GithubStatic 3000000 474 ns/op 112 B/op 2 allocs/op
|
|
||||||
BenchmarkTango_GithubStatic 1000000 1842 ns/op 256 B/op 10 allocs/op
|
## Static Routes
|
||||||
BenchmarkTigerTonic_GithubStatic 5000000 361 ns/op 48 B/op 1 allocs/op
|
|
||||||
BenchmarkTraffic_GithubStatic 30000 47197 ns/op 18920 B/op 149 allocs/op
|
```
|
||||||
BenchmarkVulcan_GithubStatic 1000000 1415 ns/op 98 B/op 3 allocs/op
|
BenchmarkGin_StaticAll 50000 34506 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkZeus_GithubStatic 1000000 2522 ns/op 512 B/op 11 allocs/op
|
|
||||||
BenchmarkAce_GithubParam 3000000 578 ns/op 96 B/op 1 allocs/op
|
BenchmarkAce_StaticAll 30000 49657 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkBear_GithubParam 1000000 1592 ns/op 464 B/op 5 allocs/op
|
BenchmarkHttpServeMux_StaticAll 2000 1183737 ns/op 96 B/op 8 allocs/op
|
||||||
BenchmarkBeego_GithubParam 1000000 2891 ns/op 784 B/op 11 allocs/op
|
BenchmarkBeego_StaticAll 5000 412621 ns/op 57776 B/op 628 allocs/op
|
||||||
BenchmarkBone_GithubParam 300000 6440 ns/op 1456 B/op 16 allocs/op
|
BenchmarkBear_StaticAll 10000 149242 ns/op 20336 B/op 461 allocs/op
|
||||||
BenchmarkDenco_GithubParam 3000000 514 ns/op 128 B/op 1 allocs/op
|
BenchmarkBone_StaticAll 10000 118583 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkEcho_GithubParam 5000000 292 ns/op 0 B/op 0 allocs/op
|
BenchmarkDenco_StaticAll 100000 13247 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkGin_GithubParam 10000000 242 ns/op 0 B/op 0 allocs/op
|
BenchmarkEcho_StaticAll 20000 79914 ns/op 5024 B/op 157 allocs/op
|
||||||
BenchmarkGocraftWeb_GithubParam 1000000 2343 ns/op 720 B/op 10 allocs/op
|
BenchmarkGocraftWeb_StaticAll 10000 211823 ns/op 46440 B/op 785 allocs/op
|
||||||
BenchmarkGoji_GithubParam 1000000 1566 ns/op 336 B/op 2 allocs/op
|
BenchmarkGoji_StaticAll 10000 109390 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkGoJsonRest_GithubParam 1000000 2828 ns/op 721 B/op 15 allocs/op
|
BenchmarkGojiv2_StaticAll 3000 415533 ns/op 145696 B/op 1099 allocs/op
|
||||||
BenchmarkGoRestful_GithubParam 10000 177711 ns/op 2816 B/op 35 allocs/op
|
BenchmarkGoJsonRest_StaticAll 5000 364403 ns/op 51653 B/op 1727 allocs/op
|
||||||
BenchmarkGorillaMux_GithubParam 100000 13591 ns/op 816 B/op 9 allocs/op
|
BenchmarkGoRestful_StaticAll 500 2578579 ns/op 314936 B/op 3144 allocs/op
|
||||||
BenchmarkHttpRouter_GithubParam 5000000 352 ns/op 96 B/op 1 allocs/op
|
BenchmarkGorillaMux_StaticAll 500 2704856 ns/op 115648 B/op 1578 allocs/op
|
||||||
BenchmarkHttpTreeMux_GithubParam 2000000 973 ns/op 336 B/op 2 allocs/op
|
BenchmarkHttpRouter_StaticAll 100000 18541 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkKocha_GithubParam 2000000 889 ns/op 128 B/op 5 allocs/op
|
BenchmarkHttpTreeMux_StaticAll 100000 22332 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkMacaron_GithubParam 500000 4047 ns/op 1168 B/op 12 allocs/op
|
BenchmarkKocha_StaticAll 50000 31176 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkMartini_GithubParam 50000 28982 ns/op 1184 B/op 12 allocs/op
|
BenchmarkLARS_StaticAll 50000 40840 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkPat_GithubParam 200000 8747 ns/op 2480 B/op 56 allocs/op
|
BenchmarkMacaron_StaticAll 5000 517656 ns/op 120576 B/op 1413 allocs/op
|
||||||
BenchmarkPossum_GithubParam 1000000 2158 ns/op 624 B/op 7 allocs/op
|
BenchmarkMartini_StaticAll 300 4462289 ns/op 125442 B/op 1717 allocs/op
|
||||||
BenchmarkR2router_GithubParam 1000000 1352 ns/op 432 B/op 6 allocs/op
|
BenchmarkPat_StaticAll 500 2157275 ns/op 533904 B/op 11123 allocs/op
|
||||||
BenchmarkRevel_GithubParam 200000 7673 ns/op 1784 B/op 30 allocs/op
|
BenchmarkPossum_StaticAll 10000 254701 ns/op 65312 B/op 471 allocs/op
|
||||||
BenchmarkRivet_GithubParam 1000000 1573 ns/op 480 B/op 6 allocs/op
|
BenchmarkR2router_StaticAll 10000 133956 ns/op 22608 B/op 628 allocs/op
|
||||||
BenchmarkTango_GithubParam 1000000 2418 ns/op 480 B/op 13 allocs/op
|
BenchmarkRivet_StaticAll 30000 46812 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkTigerTonic_GithubParam 300000 6048 ns/op 1440 B/op 28 allocs/op
|
BenchmarkTango_StaticAll 5000 390613 ns/op 39225 B/op 1256 allocs/op
|
||||||
BenchmarkTraffic_GithubParam 100000 20143 ns/op 6024 B/op 55 allocs/op
|
BenchmarkTigerTonic_StaticAll 20000 88060 ns/op 7504 B/op 157 allocs/op
|
||||||
BenchmarkVulcan_GithubParam 1000000 2224 ns/op 98 B/op 3 allocs/op
|
BenchmarkTraffic_StaticAll 500 2910236 ns/op 729736 B/op 14287 allocs/op
|
||||||
BenchmarkZeus_GithubParam 500000 4156 ns/op 1312 B/op 12 allocs/op
|
BenchmarkVulcan_StaticAll 5000 277366 ns/op 15386 B/op 471 allocs/op
|
||||||
BenchmarkAce_GithubAll 10000 109482 ns/op 13792 B/op 167 allocs/op
|
```
|
||||||
BenchmarkBear_GithubAll 10000 287490 ns/op 79952 B/op 943 allocs/op
|
|
||||||
BenchmarkBeego_GithubAll 3000 562184 ns/op 146272 B/op 2092 allocs/op
|
## Micro Benchmarks
|
||||||
BenchmarkBone_GithubAll 500 2578716 ns/op 648016 B/op 8119 allocs/op
|
|
||||||
BenchmarkDenco_GithubAll 20000 94955 ns/op 20224 B/op 167 allocs/op
|
```
|
||||||
BenchmarkEcho_GithubAll 30000 58705 ns/op 0 B/op 0 allocs/op
|
BenchmarkGin_Param 20000000 113 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkGin_GithubAll 30000 50991 ns/op 0 B/op 0 allocs/op
|
|
||||||
BenchmarkGocraftWeb_GithubAll 5000 449648 ns/op 133280 B/op 1889 allocs/op
|
BenchmarkAce_Param 5000000 375 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkGoji_GithubAll 2000 689748 ns/op 56113 B/op 334 allocs/op
|
BenchmarkBear_Param 1000000 1709 ns/op 456 B/op 5 allocs/op
|
||||||
BenchmarkGoJsonRest_GithubAll 5000 537769 ns/op 135995 B/op 2940 allocs/op
|
BenchmarkBeego_Param 1000000 2484 ns/op 368 B/op 4 allocs/op
|
||||||
BenchmarkGoRestful_GithubAll 100 18410628 ns/op 797236 B/op 7725 allocs/op
|
BenchmarkBone_Param 1000000 2391 ns/op 688 B/op 5 allocs/op
|
||||||
BenchmarkGorillaMux_GithubAll 200 8036360 ns/op 153137 B/op 1791 allocs/op
|
BenchmarkDenco_Param 10000000 240 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkHttpRouter_GithubAll 20000 63506 ns/op 13792 B/op 167 allocs/op
|
BenchmarkEcho_Param 5000000 366 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkHttpTreeMux_GithubAll 10000 165927 ns/op 56112 B/op 334 allocs/op
|
BenchmarkGocraftWeb_Param 1000000 2343 ns/op 648 B/op 8 allocs/op
|
||||||
BenchmarkKocha_GithubAll 10000 171362 ns/op 23304 B/op 843 allocs/op
|
BenchmarkGoji_Param 1000000 1197 ns/op 336 B/op 2 allocs/op
|
||||||
BenchmarkMacaron_GithubAll 2000 817008 ns/op 224960 B/op 2315 allocs/op
|
BenchmarkGojiv2_Param 1000000 2771 ns/op 944 B/op 8 allocs/op
|
||||||
BenchmarkMartini_GithubAll 100 12609209 ns/op 237952 B/op 2686 allocs/op
|
BenchmarkGoJsonRest_Param 1000000 2993 ns/op 649 B/op 13 allocs/op
|
||||||
BenchmarkPat_GithubAll 300 4830398 ns/op 1504101 B/op 32222 allocs/op
|
BenchmarkGoRestful_Param 200000 8860 ns/op 2296 B/op 21 allocs/op
|
||||||
BenchmarkPossum_GithubAll 10000 301716 ns/op 97440 B/op 812 allocs/op
|
BenchmarkGorillaMux_Param 500000 4461 ns/op 1056 B/op 11 allocs/op
|
||||||
BenchmarkR2router_GithubAll 10000 270691 ns/op 77328 B/op 1182 allocs/op
|
BenchmarkHttpRouter_Param 10000000 175 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkRevel_GithubAll 1000 1491919 ns/op 345553 B/op 5918 allocs/op
|
BenchmarkHttpTreeMux_Param 1000000 1167 ns/op 352 B/op 3 allocs/op
|
||||||
BenchmarkRivet_GithubAll 10000 283860 ns/op 84272 B/op 1079 allocs/op
|
BenchmarkKocha_Param 3000000 429 ns/op 56 B/op 3 allocs/op
|
||||||
BenchmarkTango_GithubAll 5000 473821 ns/op 87078 B/op 2470 allocs/op
|
BenchmarkLARS_Param 10000000 134 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkTigerTonic_GithubAll 2000 1120131 ns/op 241088 B/op 6052 allocs/op
|
BenchmarkMacaron_Param 500000 4635 ns/op 1056 B/op 10 allocs/op
|
||||||
BenchmarkTraffic_GithubAll 200 8708979 ns/op 2664762 B/op 22390 allocs/op
|
BenchmarkMartini_Param 200000 9933 ns/op 1072 B/op 10 allocs/op
|
||||||
BenchmarkVulcan_GithubAll 5000 353392 ns/op 19894 B/op 609 allocs/op
|
BenchmarkPat_Param 1000000 2929 ns/op 648 B/op 12 allocs/op
|
||||||
BenchmarkZeus_GithubAll 2000 944234 ns/op 300688 B/op 2648 allocs/op
|
BenchmarkPossum_Param 1000000 2503 ns/op 560 B/op 6 allocs/op
|
||||||
BenchmarkAce_GPlusStatic 5000000 251 ns/op 0 B/op 0 allocs/op
|
BenchmarkR2router_Param 1000000 1507 ns/op 432 B/op 5 allocs/op
|
||||||
BenchmarkBear_GPlusStatic 3000000 415 ns/op 72 B/op 3 allocs/op
|
BenchmarkRivet_Param 5000000 297 ns/op 48 B/op 1 allocs/op
|
||||||
BenchmarkBeego_GPlusStatic 1000000 1416 ns/op 352 B/op 7 allocs/op
|
BenchmarkTango_Param 1000000 1862 ns/op 248 B/op 8 allocs/op
|
||||||
BenchmarkBone_GPlusStatic 10000000 192 ns/op 32 B/op 1 allocs/op
|
BenchmarkTigerTonic_Param 500000 5660 ns/op 992 B/op 17 allocs/op
|
||||||
BenchmarkDenco_GPlusStatic 30000000 47.6 ns/op 0 B/op 0 allocs/op
|
BenchmarkTraffic_Param 200000 8408 ns/op 1960 B/op 21 allocs/op
|
||||||
BenchmarkEcho_GPlusStatic 10000000 131 ns/op 0 B/op 0 allocs/op
|
BenchmarkVulcan_Param 2000000 963 ns/op 98 B/op 3 allocs/op
|
||||||
BenchmarkGin_GPlusStatic 10000000 131 ns/op 0 B/op 0 allocs/op
|
BenchmarkAce_Param5 2000000 740 ns/op 160 B/op 1 allocs/op
|
||||||
BenchmarkGocraftWeb_GPlusStatic 1000000 1035 ns/op 288 B/op 6 allocs/op
|
BenchmarkBear_Param5 1000000 2777 ns/op 501 B/op 5 allocs/op
|
||||||
BenchmarkGoji_GPlusStatic 5000000 304 ns/op 0 B/op 0 allocs/op
|
BenchmarkBeego_Param5 1000000 3740 ns/op 368 B/op 4 allocs/op
|
||||||
BenchmarkGoJsonRest_GPlusStatic 1000000 1286 ns/op 337 B/op 12 allocs/op
|
BenchmarkBone_Param5 1000000 2950 ns/op 736 B/op 5 allocs/op
|
||||||
BenchmarkGoRestful_GPlusStatic 200000 9649 ns/op 2160 B/op 30 allocs/op
|
BenchmarkDenco_Param5 2000000 644 ns/op 160 B/op 1 allocs/op
|
||||||
BenchmarkGorillaMux_GPlusStatic 1000000 2346 ns/op 464 B/op 8 allocs/op
|
BenchmarkEcho_Param5 3000000 558 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkHttpRouter_GPlusStatic 30000000 42.7 ns/op 0 B/op 0 allocs/op
|
BenchmarkGin_Param5 10000000 198 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkHttpTreeMux_GPlusStatic 30000000 49.5 ns/op 0 B/op 0 allocs/op
|
BenchmarkGocraftWeb_Param5 500000 3870 ns/op 920 B/op 11 allocs/op
|
||||||
BenchmarkKocha_GPlusStatic 20000000 74.8 ns/op 0 B/op 0 allocs/op
|
BenchmarkGoji_Param5 1000000 1746 ns/op 336 B/op 2 allocs/op
|
||||||
BenchmarkMacaron_GPlusStatic 1000000 2520 ns/op 736 B/op 8 allocs/op
|
BenchmarkGojiv2_Param5 1000000 3214 ns/op 1008 B/op 8 allocs/op
|
||||||
BenchmarkMartini_GPlusStatic 300000 5310 ns/op 832 B/op 11 allocs/op
|
BenchmarkGoJsonRest_Param5 500000 5509 ns/op 1097 B/op 16 allocs/op
|
||||||
BenchmarkPat_GPlusStatic 5000000 398 ns/op 96 B/op 2 allocs/op
|
BenchmarkGoRestful_Param5 200000 11232 ns/op 2392 B/op 21 allocs/op
|
||||||
BenchmarkPossum_GPlusStatic 1000000 1434 ns/op 480 B/op 4 allocs/op
|
BenchmarkGorillaMux_Param5 300000 7777 ns/op 1184 B/op 11 allocs/op
|
||||||
BenchmarkR2router_GPlusStatic 2000000 646 ns/op 144 B/op 5 allocs/op
|
BenchmarkHttpRouter_Param5 3000000 631 ns/op 160 B/op 1 allocs/op
|
||||||
BenchmarkRevel_GPlusStatic 300000 6172 ns/op 1272 B/op 25 allocs/op
|
BenchmarkHttpTreeMux_Param5 1000000 2800 ns/op 576 B/op 6 allocs/op
|
||||||
BenchmarkRivet_GPlusStatic 3000000 444 ns/op 112 B/op 2 allocs/op
|
BenchmarkKocha_Param5 1000000 2053 ns/op 440 B/op 10 allocs/op
|
||||||
BenchmarkTango_GPlusStatic 1000000 1400 ns/op 208 B/op 10 allocs/op
|
BenchmarkLARS_Param5 10000000 232 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkTigerTonic_GPlusStatic 10000000 213 ns/op 32 B/op 1 allocs/op
|
BenchmarkMacaron_Param5 500000 5888 ns/op 1056 B/op 10 allocs/op
|
||||||
BenchmarkTraffic_GPlusStatic 1000000 3091 ns/op 1208 B/op 16 allocs/op
|
BenchmarkMartini_Param5 200000 12807 ns/op 1232 B/op 11 allocs/op
|
||||||
BenchmarkVulcan_GPlusStatic 2000000 863 ns/op 98 B/op 3 allocs/op
|
BenchmarkPat_Param5 300000 7320 ns/op 964 B/op 32 allocs/op
|
||||||
BenchmarkZeus_GPlusStatic 10000000 237 ns/op 16 B/op 1 allocs/op
|
BenchmarkPossum_Param5 1000000 2495 ns/op 560 B/op 6 allocs/op
|
||||||
BenchmarkAce_GPlusParam 3000000 435 ns/op 64 B/op 1 allocs/op
|
BenchmarkR2router_Param5 1000000 1844 ns/op 432 B/op 5 allocs/op
|
||||||
BenchmarkBear_GPlusParam 1000000 1205 ns/op 448 B/op 5 allocs/op
|
BenchmarkRivet_Param5 2000000 935 ns/op 240 B/op 1 allocs/op
|
||||||
BenchmarkBeego_GPlusParam 1000000 2494 ns/op 720 B/op 10 allocs/op
|
BenchmarkTango_Param5 1000000 2327 ns/op 360 B/op 8 allocs/op
|
||||||
BenchmarkBone_GPlusParam 1000000 1126 ns/op 384 B/op 3 allocs/op
|
BenchmarkTigerTonic_Param5 100000 18514 ns/op 2551 B/op 43 allocs/op
|
||||||
BenchmarkDenco_GPlusParam 5000000 325 ns/op 64 B/op 1 allocs/op
|
BenchmarkTraffic_Param5 200000 11997 ns/op 2248 B/op 25 allocs/op
|
||||||
BenchmarkEcho_GPlusParam 10000000 168 ns/op 0 B/op 0 allocs/op
|
BenchmarkVulcan_Param5 1000000 1333 ns/op 98 B/op 3 allocs/op
|
||||||
BenchmarkGin_GPlusParam 10000000 170 ns/op 0 B/op 0 allocs/op
|
BenchmarkAce_Param20 1000000 2031 ns/op 640 B/op 1 allocs/op
|
||||||
BenchmarkGocraftWeb_GPlusParam 1000000 1895 ns/op 656 B/op 9 allocs/op
|
BenchmarkBear_Param20 200000 7285 ns/op 1664 B/op 5 allocs/op
|
||||||
BenchmarkGoji_GPlusParam 1000000 1071 ns/op 336 B/op 2 allocs/op
|
BenchmarkBeego_Param20 300000 6224 ns/op 368 B/op 4 allocs/op
|
||||||
BenchmarkGoJsonRest_GPlusParam 1000000 2282 ns/op 657 B/op 14 allocs/op
|
BenchmarkBone_Param20 200000 8023 ns/op 1903 B/op 5 allocs/op
|
||||||
BenchmarkGoRestful_GPlusParam 100000 19400 ns/op 2560 B/op 33 allocs/op
|
BenchmarkDenco_Param20 1000000 2262 ns/op 640 B/op 1 allocs/op
|
||||||
BenchmarkGorillaMux_GPlusParam 500000 5001 ns/op 784 B/op 9 allocs/op
|
BenchmarkEcho_Param20 1000000 1387 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkHttpRouter_GPlusParam 10000000 240 ns/op 64 B/op 1 allocs/op
|
BenchmarkGin_Param20 3000000 503 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkHttpTreeMux_GPlusParam 2000000 797 ns/op 336 B/op 2 allocs/op
|
BenchmarkGocraftWeb_Param20 100000 14408 ns/op 3795 B/op 15 allocs/op
|
||||||
BenchmarkKocha_GPlusParam 3000000 505 ns/op 56 B/op 3 allocs/op
|
BenchmarkGoji_Param20 500000 5272 ns/op 1247 B/op 2 allocs/op
|
||||||
BenchmarkMacaron_GPlusParam 1000000 3668 ns/op 1104 B/op 11 allocs/op
|
BenchmarkGojiv2_Param20 1000000 4163 ns/op 1248 B/op 8 allocs/op
|
||||||
BenchmarkMartini_GPlusParam 200000 10672 ns/op 1152 B/op 12 allocs/op
|
BenchmarkGoJsonRest_Param20 100000 17866 ns/op 4485 B/op 20 allocs/op
|
||||||
BenchmarkPat_GPlusParam 1000000 2376 ns/op 704 B/op 14 allocs/op
|
BenchmarkGoRestful_Param20 100000 21022 ns/op 4724 B/op 23 allocs/op
|
||||||
BenchmarkPossum_GPlusParam 1000000 2090 ns/op 624 B/op 7 allocs/op
|
BenchmarkGorillaMux_Param20 100000 17055 ns/op 3547 B/op 13 allocs/op
|
||||||
BenchmarkR2router_GPlusParam 1000000 1233 ns/op 432 B/op 6 allocs/op
|
BenchmarkHttpRouter_Param20 1000000 1748 ns/op 640 B/op 1 allocs/op
|
||||||
BenchmarkRevel_GPlusParam 200000 6778 ns/op 1704 B/op 28 allocs/op
|
BenchmarkHttpTreeMux_Param20 200000 12246 ns/op 3196 B/op 10 allocs/op
|
||||||
BenchmarkRivet_GPlusParam 1000000 1279 ns/op 464 B/op 5 allocs/op
|
BenchmarkKocha_Param20 300000 6861 ns/op 1808 B/op 27 allocs/op
|
||||||
BenchmarkTango_GPlusParam 1000000 1981 ns/op 272 B/op 10 allocs/op
|
BenchmarkLARS_Param20 3000000 526 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkTigerTonic_GPlusParam 500000 3893 ns/op 1064 B/op 19 allocs/op
|
BenchmarkMacaron_Param20 100000 13069 ns/op 2906 B/op 12 allocs/op
|
||||||
BenchmarkTraffic_GPlusParam 200000 6585 ns/op 2000 B/op 23 allocs/op
|
BenchmarkMartini_Param20 100000 23602 ns/op 3597 B/op 13 allocs/op
|
||||||
BenchmarkVulcan_GPlusParam 1000000 1233 ns/op 98 B/op 3 allocs/op
|
BenchmarkPat_Param20 50000 32143 ns/op 4688 B/op 111 allocs/op
|
||||||
BenchmarkZeus_GPlusParam 1000000 1350 ns/op 368 B/op 3 allocs/op
|
BenchmarkPossum_Param20 1000000 2396 ns/op 560 B/op 6 allocs/op
|
||||||
BenchmarkAce_GPlus2Params 3000000 512 ns/op 64 B/op 1 allocs/op
|
BenchmarkR2router_Param20 200000 8907 ns/op 2283 B/op 7 allocs/op
|
||||||
BenchmarkBear_GPlus2Params 1000000 1564 ns/op 464 B/op 5 allocs/op
|
BenchmarkRivet_Param20 1000000 3280 ns/op 1024 B/op 1 allocs/op
|
||||||
BenchmarkBeego_GPlus2Params 1000000 3043 ns/op 784 B/op 11 allocs/op
|
BenchmarkTango_Param20 500000 4640 ns/op 856 B/op 8 allocs/op
|
||||||
BenchmarkBone_GPlus2Params 1000000 3152 ns/op 736 B/op 7 allocs/op
|
BenchmarkTigerTonic_Param20 20000 67581 ns/op 10532 B/op 138 allocs/op
|
||||||
BenchmarkDenco_GPlus2Params 3000000 431 ns/op 64 B/op 1 allocs/op
|
BenchmarkTraffic_Param20 50000 40313 ns/op 7941 B/op 45 allocs/op
|
||||||
BenchmarkEcho_GPlus2Params 5000000 247 ns/op 0 B/op 0 allocs/op
|
BenchmarkVulcan_Param20 1000000 2264 ns/op 98 B/op 3 allocs/op
|
||||||
BenchmarkGin_GPlus2Params 10000000 219 ns/op 0 B/op 0 allocs/op
|
BenchmarkAce_ParamWrite 3000000 532 ns/op 40 B/op 2 allocs/op
|
||||||
BenchmarkGocraftWeb_GPlus2Params 1000000 2363 ns/op 720 B/op 10 allocs/op
|
BenchmarkBear_ParamWrite 1000000 1778 ns/op 456 B/op 5 allocs/op
|
||||||
BenchmarkGoji_GPlus2Params 1000000 1540 ns/op 336 B/op 2 allocs/op
|
BenchmarkBeego_ParamWrite 1000000 2596 ns/op 376 B/op 5 allocs/op
|
||||||
BenchmarkGoJsonRest_GPlus2Params 1000000 2872 ns/op 721 B/op 15 allocs/op
|
BenchmarkBone_ParamWrite 1000000 2519 ns/op 688 B/op 5 allocs/op
|
||||||
BenchmarkGoRestful_GPlus2Params 100000 23030 ns/op 2720 B/op 35 allocs/op
|
BenchmarkDenco_ParamWrite 5000000 411 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkGorillaMux_GPlus2Params 200000 10516 ns/op 816 B/op 9 allocs/op
|
BenchmarkEcho_ParamWrite 2000000 718 ns/op 40 B/op 2 allocs/op
|
||||||
BenchmarkHttpRouter_GPlus2Params 5000000 273 ns/op 64 B/op 1 allocs/op
|
BenchmarkGin_ParamWrite 5000000 283 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkHttpTreeMux_GPlus2Params 2000000 939 ns/op 336 B/op 2 allocs/op
|
BenchmarkGocraftWeb_ParamWrite 1000000 2561 ns/op 656 B/op 9 allocs/op
|
||||||
BenchmarkKocha_GPlus2Params 2000000 844 ns/op 128 B/op 5 allocs/op
|
BenchmarkGoji_ParamWrite 1000000 1378 ns/op 336 B/op 2 allocs/op
|
||||||
BenchmarkMacaron_GPlus2Params 500000 3914 ns/op 1168 B/op 12 allocs/op
|
BenchmarkGojiv2_ParamWrite 1000000 3128 ns/op 976 B/op 10 allocs/op
|
||||||
BenchmarkMartini_GPlus2Params 50000 35759 ns/op 1280 B/op 16 allocs/op
|
BenchmarkGoJsonRest_ParamWrite 500000 4446 ns/op 1128 B/op 18 allocs/op
|
||||||
BenchmarkPat_GPlus2Params 200000 7089 ns/op 2304 B/op 41 allocs/op
|
BenchmarkGoRestful_ParamWrite 200000 10291 ns/op 2304 B/op 22 allocs/op
|
||||||
BenchmarkPossum_GPlus2Params 1000000 2093 ns/op 624 B/op 7 allocs/op
|
BenchmarkGorillaMux_ParamWrite 500000 5153 ns/op 1064 B/op 12 allocs/op
|
||||||
BenchmarkR2router_GPlus2Params 1000000 1320 ns/op 432 B/op 6 allocs/op
|
BenchmarkHttpRouter_ParamWrite 5000000 263 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkRevel_GPlus2Params 200000 7351 ns/op 1800 B/op 30 allocs/op
|
BenchmarkHttpTreeMux_ParamWrite 1000000 1351 ns/op 352 B/op 3 allocs/op
|
||||||
BenchmarkRivet_GPlus2Params 1000000 1485 ns/op 480 B/op 6 allocs/op
|
BenchmarkKocha_ParamWrite 3000000 538 ns/op 56 B/op 3 allocs/op
|
||||||
BenchmarkTango_GPlus2Params 1000000 2111 ns/op 448 B/op 12 allocs/op
|
BenchmarkLARS_ParamWrite 5000000 316 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkTigerTonic_GPlus2Params 300000 6271 ns/op 1528 B/op 28 allocs/op
|
BenchmarkMacaron_ParamWrite 500000 5756 ns/op 1160 B/op 14 allocs/op
|
||||||
BenchmarkTraffic_GPlus2Params 100000 14886 ns/op 3312 B/op 34 allocs/op
|
BenchmarkMartini_ParamWrite 200000 13097 ns/op 1176 B/op 14 allocs/op
|
||||||
BenchmarkVulcan_GPlus2Params 1000000 1883 ns/op 98 B/op 3 allocs/op
|
BenchmarkPat_ParamWrite 500000 4954 ns/op 1072 B/op 17 allocs/op
|
||||||
BenchmarkZeus_GPlus2Params 1000000 2686 ns/op 784 B/op 6 allocs/op
|
BenchmarkPossum_ParamWrite 1000000 2499 ns/op 560 B/op 6 allocs/op
|
||||||
BenchmarkAce_GPlusAll 300000 5912 ns/op 640 B/op 11 allocs/op
|
BenchmarkR2router_ParamWrite 1000000 1531 ns/op 432 B/op 5 allocs/op
|
||||||
BenchmarkBear_GPlusAll 100000 16448 ns/op 5072 B/op 61 allocs/op
|
BenchmarkRivet_ParamWrite 3000000 570 ns/op 112 B/op 2 allocs/op
|
||||||
BenchmarkBeego_GPlusAll 50000 32916 ns/op 8976 B/op 129 allocs/op
|
BenchmarkTango_ParamWrite 2000000 957 ns/op 136 B/op 4 allocs/op
|
||||||
BenchmarkBone_GPlusAll 50000 25836 ns/op 6992 B/op 76 allocs/op
|
BenchmarkTigerTonic_ParamWrite 200000 7025 ns/op 1424 B/op 23 allocs/op
|
||||||
BenchmarkDenco_GPlusAll 500000 4462 ns/op 672 B/op 11 allocs/op
|
BenchmarkTraffic_ParamWrite 200000 10112 ns/op 2384 B/op 25 allocs/op
|
||||||
BenchmarkEcho_GPlusAll 500000 2806 ns/op 0 B/op 0 allocs/op
|
BenchmarkVulcan_ParamWrite 1000000 1006 ns/op 98 B/op 3 allocs/op
|
||||||
BenchmarkGin_GPlusAll 500000 2579 ns/op 0 B/op 0 allocs/op
|
```
|
||||||
BenchmarkGocraftWeb_GPlusAll 50000 25223 ns/op 8144 B/op 116 allocs/op
|
|
||||||
BenchmarkGoji_GPlusAll 100000 14237 ns/op 3696 B/op 22 allocs/op
|
## GitHub
|
||||||
BenchmarkGoJsonRest_GPlusAll 50000 29227 ns/op 8221 B/op 183 allocs/op
|
|
||||||
BenchmarkGoRestful_GPlusAll 10000 203144 ns/op 36064 B/op 441 allocs/op
|
```
|
||||||
BenchmarkGorillaMux_GPlusAll 20000 80906 ns/op 9712 B/op 115 allocs/op
|
BenchmarkGin_GithubStatic 10000000 156 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkHttpRouter_GPlusAll 500000 3040 ns/op 640 B/op 11 allocs/op
|
|
||||||
BenchmarkHttpTreeMux_GPlusAll 200000 9627 ns/op 3696 B/op 22 allocs/op
|
BenchmarkAce_GithubStatic 5000000 294 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkKocha_GPlusAll 200000 8108 ns/op 976 B/op 43 allocs/op
|
BenchmarkBear_GithubStatic 2000000 893 ns/op 120 B/op 3 allocs/op
|
||||||
BenchmarkMacaron_GPlusAll 30000 48083 ns/op 13968 B/op 142 allocs/op
|
BenchmarkBeego_GithubStatic 1000000 2491 ns/op 368 B/op 4 allocs/op
|
||||||
BenchmarkMartini_GPlusAll 10000 196978 ns/op 15072 B/op 178 allocs/op
|
BenchmarkBone_GithubStatic 50000 25300 ns/op 2880 B/op 60 allocs/op
|
||||||
BenchmarkPat_GPlusAll 30000 58865 ns/op 16880 B/op 343 allocs/op
|
BenchmarkDenco_GithubStatic 20000000 76.0 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkPossum_GPlusAll 100000 19685 ns/op 6240 B/op 52 allocs/op
|
BenchmarkEcho_GithubStatic 2000000 516 ns/op 32 B/op 1 allocs/op
|
||||||
BenchmarkR2router_GPlusAll 100000 16251 ns/op 5040 B/op 76 allocs/op
|
BenchmarkGocraftWeb_GithubStatic 1000000 1448 ns/op 296 B/op 5 allocs/op
|
||||||
BenchmarkRevel_GPlusAll 20000 93489 ns/op 21656 B/op 368 allocs/op
|
BenchmarkGoji_GithubStatic 3000000 496 ns/op 0 B/op 0 allocs/op
|
||||||
BenchmarkRivet_GPlusAll 100000 16907 ns/op 5408 B/op 64 allocs/op
|
BenchmarkGojiv2_GithubStatic 1000000 2941 ns/op 928 B/op 7 allocs/op
|
||||||
|
BenchmarkGoRestful_GithubStatic 100000 27256 ns/op 3224 B/op 22 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GithubStatic 1000000 2196 ns/op 329 B/op 11 allocs/op
|
||||||
|
BenchmarkGorillaMux_GithubStatic 50000 31617 ns/op 736 B/op 10 allocs/op
|
||||||
|
BenchmarkHttpRouter_GithubStatic 20000000 88.4 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GithubStatic 10000000 134 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkKocha_GithubStatic 20000000 113 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkLARS_GithubStatic 10000000 195 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GithubStatic 500000 3740 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkMartini_GithubStatic 50000 27673 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkPat_GithubStatic 100000 19470 ns/op 3648 B/op 76 allocs/op
|
||||||
|
BenchmarkPossum_GithubStatic 1000000 1729 ns/op 416 B/op 3 allocs/op
|
||||||
|
BenchmarkR2router_GithubStatic 2000000 879 ns/op 144 B/op 4 allocs/op
|
||||||
|
BenchmarkRivet_GithubStatic 10000000 231 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkTango_GithubStatic 1000000 2325 ns/op 248 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_GithubStatic 3000000 610 ns/op 48 B/op 1 allocs/op
|
||||||
|
BenchmarkTraffic_GithubStatic 20000 62973 ns/op 18904 B/op 148 allocs/op
|
||||||
|
BenchmarkVulcan_GithubStatic 1000000 1447 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_GithubParam 2000000 686 ns/op 96 B/op 1 allocs/op
|
||||||
|
BenchmarkBear_GithubParam 1000000 2155 ns/op 496 B/op 5 allocs/op
|
||||||
|
BenchmarkBeego_GithubParam 1000000 2713 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_GithubParam 100000 15088 ns/op 1760 B/op 18 allocs/op
|
||||||
|
BenchmarkDenco_GithubParam 2000000 629 ns/op 128 B/op 1 allocs/op
|
||||||
|
BenchmarkEcho_GithubParam 2000000 653 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGin_GithubParam 5000000 255 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GithubParam 1000000 3145 ns/op 712 B/op 9 allocs/op
|
||||||
|
BenchmarkGoji_GithubParam 1000000 1916 ns/op 336 B/op 2 allocs/op
|
||||||
|
BenchmarkGojiv2_GithubParam 1000000 3975 ns/op 1024 B/op 10 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GithubParam 300000 4134 ns/op 713 B/op 14 allocs/op
|
||||||
|
BenchmarkGoRestful_GithubParam 50000 30782 ns/op 2360 B/op 21 allocs/op
|
||||||
|
BenchmarkGorillaMux_GithubParam 100000 17148 ns/op 1088 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpRouter_GithubParam 3000000 523 ns/op 96 B/op 1 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GithubParam 1000000 1671 ns/op 384 B/op 4 allocs/op
|
||||||
|
BenchmarkKocha_GithubParam 1000000 1021 ns/op 128 B/op 5 allocs/op
|
||||||
|
BenchmarkLARS_GithubParam 5000000 283 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GithubParam 500000 4270 ns/op 1056 B/op 10 allocs/op
|
||||||
|
BenchmarkMartini_GithubParam 100000 21728 ns/op 1152 B/op 11 allocs/op
|
||||||
|
BenchmarkPat_GithubParam 200000 11208 ns/op 2464 B/op 48 allocs/op
|
||||||
|
BenchmarkPossum_GithubParam 1000000 2334 ns/op 560 B/op 6 allocs/op
|
||||||
|
BenchmarkR2router_GithubParam 1000000 1487 ns/op 432 B/op 5 allocs/op
|
||||||
|
BenchmarkRivet_GithubParam 2000000 782 ns/op 96 B/op 1 allocs/op
|
||||||
|
BenchmarkTango_GithubParam 1000000 2653 ns/op 344 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_GithubParam 300000 14073 ns/op 1440 B/op 24 allocs/op
|
||||||
|
BenchmarkTraffic_GithubParam 50000 29164 ns/op 5992 B/op 52 allocs/op
|
||||||
|
BenchmarkVulcan_GithubParam 1000000 2529 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_GithubAll 10000 134059 ns/op 13792 B/op 167 allocs/op
|
||||||
|
BenchmarkBear_GithubAll 5000 534445 ns/op 86448 B/op 943 allocs/op
|
||||||
|
BenchmarkBeego_GithubAll 3000 592444 ns/op 74705 B/op 812 allocs/op
|
||||||
|
BenchmarkBone_GithubAll 200 6957308 ns/op 698784 B/op 8453 allocs/op
|
||||||
|
BenchmarkDenco_GithubAll 10000 158819 ns/op 20224 B/op 167 allocs/op
|
||||||
|
BenchmarkEcho_GithubAll 10000 154700 ns/op 6496 B/op 203 allocs/op
|
||||||
|
BenchmarkGin_GithubAll 30000 48375 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GithubAll 3000 570806 ns/op 131656 B/op 1686 allocs/op
|
||||||
|
BenchmarkGoji_GithubAll 2000 818034 ns/op 56112 B/op 334 allocs/op
|
||||||
|
BenchmarkGojiv2_GithubAll 2000 1213973 ns/op 274768 B/op 3712 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GithubAll 2000 785796 ns/op 134371 B/op 2737 allocs/op
|
||||||
|
BenchmarkGoRestful_GithubAll 300 5238188 ns/op 689672 B/op 4519 allocs/op
|
||||||
|
BenchmarkGorillaMux_GithubAll 100 10257726 ns/op 211840 B/op 2272 allocs/op
|
||||||
|
BenchmarkHttpRouter_GithubAll 20000 105414 ns/op 13792 B/op 167 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GithubAll 10000 319934 ns/op 65856 B/op 671 allocs/op
|
||||||
|
BenchmarkKocha_GithubAll 10000 209442 ns/op 23304 B/op 843 allocs/op
|
||||||
|
BenchmarkLARS_GithubAll 20000 62565 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GithubAll 2000 1161270 ns/op 204194 B/op 2000 allocs/op
|
||||||
|
BenchmarkMartini_GithubAll 200 9991713 ns/op 226549 B/op 2325 allocs/op
|
||||||
|
BenchmarkPat_GithubAll 200 5590793 ns/op 1499568 B/op 27435 allocs/op
|
||||||
|
BenchmarkPossum_GithubAll 10000 319768 ns/op 84448 B/op 609 allocs/op
|
||||||
|
BenchmarkR2router_GithubAll 10000 305134 ns/op 77328 B/op 979 allocs/op
|
||||||
|
BenchmarkRivet_GithubAll 10000 132134 ns/op 16272 B/op 167 allocs/op
|
||||||
|
BenchmarkTango_GithubAll 3000 552754 ns/op 63826 B/op 1618 allocs/op
|
||||||
|
BenchmarkTigerTonic_GithubAll 1000 1439483 ns/op 239104 B/op 5374 allocs/op
|
||||||
|
BenchmarkTraffic_GithubAll 100 11383067 ns/op 2659329 B/op 21848 allocs/op
|
||||||
|
BenchmarkVulcan_GithubAll 5000 394253 ns/op 19894 B/op 609 allocs/op
|
||||||
|
```
|
||||||
|
|
||||||
|
## Google+
|
||||||
|
|
||||||
|
```
|
||||||
|
BenchmarkGin_GPlusStatic 10000000 183 ns/op 0 B/op 0 allocs/op
|
||||||
|
|
||||||
|
BenchmarkAce_GPlusStatic 5000000 276 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkBear_GPlusStatic 2000000 652 ns/op 104 B/op 3 allocs/op
|
||||||
|
BenchmarkBeego_GPlusStatic 1000000 2239 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_GPlusStatic 5000000 380 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkDenco_GPlusStatic 30000000 45.8 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkEcho_GPlusStatic 5000000 338 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GPlusStatic 1000000 1158 ns/op 280 B/op 5 allocs/op
|
||||||
|
BenchmarkGoji_GPlusStatic 5000000 331 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGojiv2_GPlusStatic 1000000 2106 ns/op 928 B/op 7 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GPlusStatic 1000000 1626 ns/op 329 B/op 11 allocs/op
|
||||||
|
BenchmarkGoRestful_GPlusStatic 300000 7598 ns/op 1976 B/op 20 allocs/op
|
||||||
|
BenchmarkGorillaMux_GPlusStatic 1000000 2629 ns/op 736 B/op 10 allocs/op
|
||||||
|
BenchmarkHttpRouter_GPlusStatic 30000000 52.5 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GPlusStatic 20000000 85.8 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkKocha_GPlusStatic 20000000 89.2 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkLARS_GPlusStatic 10000000 162 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GPlusStatic 500000 3479 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkMartini_GPlusStatic 200000 9092 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkPat_GPlusStatic 3000000 493 ns/op 96 B/op 2 allocs/op
|
||||||
|
BenchmarkPossum_GPlusStatic 1000000 1467 ns/op 416 B/op 3 allocs/op
|
||||||
|
BenchmarkR2router_GPlusStatic 2000000 788 ns/op 144 B/op 4 allocs/op
|
||||||
|
BenchmarkRivet_GPlusStatic 20000000 114 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkTango_GPlusStatic 1000000 1534 ns/op 200 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_GPlusStatic 5000000 282 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkTraffic_GPlusStatic 500000 3798 ns/op 1192 B/op 15 allocs/op
|
||||||
|
BenchmarkVulcan_GPlusStatic 2000000 1125 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_GPlusParam 3000000 528 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkBear_GPlusParam 1000000 1570 ns/op 480 B/op 5 allocs/op
|
||||||
|
BenchmarkBeego_GPlusParam 1000000 2369 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_GPlusParam 1000000 2028 ns/op 688 B/op 5 allocs/op
|
||||||
|
BenchmarkDenco_GPlusParam 5000000 385 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkEcho_GPlusParam 3000000 441 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGin_GPlusParam 10000000 174 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GPlusParam 1000000 2033 ns/op 648 B/op 8 allocs/op
|
||||||
|
BenchmarkGoji_GPlusParam 1000000 1399 ns/op 336 B/op 2 allocs/op
|
||||||
|
BenchmarkGojiv2_GPlusParam 1000000 2641 ns/op 944 B/op 8 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GPlusParam 1000000 2824 ns/op 649 B/op 13 allocs/op
|
||||||
|
BenchmarkGoRestful_GPlusParam 200000 8875 ns/op 2296 B/op 21 allocs/op
|
||||||
|
BenchmarkGorillaMux_GPlusParam 200000 6291 ns/op 1056 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpRouter_GPlusParam 5000000 316 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GPlusParam 1000000 1129 ns/op 352 B/op 3 allocs/op
|
||||||
|
BenchmarkKocha_GPlusParam 3000000 538 ns/op 56 B/op 3 allocs/op
|
||||||
|
BenchmarkLARS_GPlusParam 10000000 198 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GPlusParam 500000 3554 ns/op 1056 B/op 10 allocs/op
|
||||||
|
BenchmarkMartini_GPlusParam 200000 9831 ns/op 1072 B/op 10 allocs/op
|
||||||
|
BenchmarkPat_GPlusParam 1000000 2706 ns/op 688 B/op 12 allocs/op
|
||||||
|
BenchmarkPossum_GPlusParam 1000000 2297 ns/op 560 B/op 6 allocs/op
|
||||||
|
BenchmarkR2router_GPlusParam 1000000 1318 ns/op 432 B/op 5 allocs/op
|
||||||
|
BenchmarkRivet_GPlusParam 5000000 399 ns/op 48 B/op 1 allocs/op
|
||||||
|
BenchmarkTango_GPlusParam 1000000 2070 ns/op 264 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_GPlusParam 500000 4853 ns/op 1056 B/op 17 allocs/op
|
||||||
|
BenchmarkTraffic_GPlusParam 200000 8278 ns/op 1976 B/op 21 allocs/op
|
||||||
|
BenchmarkVulcan_GPlusParam 1000000 1243 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_GPlus2Params 3000000 549 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkBear_GPlus2Params 1000000 2112 ns/op 496 B/op 5 allocs/op
|
||||||
|
BenchmarkBeego_GPlus2Params 500000 2750 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_GPlus2Params 300000 7032 ns/op 1040 B/op 9 allocs/op
|
||||||
|
BenchmarkDenco_GPlus2Params 3000000 502 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkEcho_GPlus2Params 3000000 641 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGin_GPlus2Params 5000000 250 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GPlus2Params 1000000 2681 ns/op 712 B/op 9 allocs/op
|
||||||
|
BenchmarkGoji_GPlus2Params 1000000 1926 ns/op 336 B/op 2 allocs/op
|
||||||
|
BenchmarkGojiv2_GPlus2Params 500000 3996 ns/op 1024 B/op 11 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GPlus2Params 500000 3886 ns/op 713 B/op 14 allocs/op
|
||||||
|
BenchmarkGoRestful_GPlus2Params 200000 10376 ns/op 2360 B/op 21 allocs/op
|
||||||
|
BenchmarkGorillaMux_GPlus2Params 100000 14162 ns/op 1088 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpRouter_GPlus2Params 5000000 336 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GPlus2Params 1000000 1523 ns/op 384 B/op 4 allocs/op
|
||||||
|
BenchmarkKocha_GPlus2Params 2000000 970 ns/op 128 B/op 5 allocs/op
|
||||||
|
BenchmarkLARS_GPlus2Params 5000000 238 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GPlus2Params 500000 4016 ns/op 1056 B/op 10 allocs/op
|
||||||
|
BenchmarkMartini_GPlus2Params 100000 21253 ns/op 1200 B/op 13 allocs/op
|
||||||
|
BenchmarkPat_GPlus2Params 200000 8632 ns/op 2256 B/op 34 allocs/op
|
||||||
|
BenchmarkPossum_GPlus2Params 1000000 2171 ns/op 560 B/op 6 allocs/op
|
||||||
|
BenchmarkR2router_GPlus2Params 1000000 1340 ns/op 432 B/op 5 allocs/op
|
||||||
|
BenchmarkRivet_GPlus2Params 3000000 557 ns/op 96 B/op 1 allocs/op
|
||||||
|
BenchmarkTango_GPlus2Params 1000000 2186 ns/op 344 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_GPlus2Params 200000 9060 ns/op 1488 B/op 24 allocs/op
|
||||||
|
BenchmarkTraffic_GPlus2Params 100000 20324 ns/op 3272 B/op 31 allocs/op
|
||||||
|
BenchmarkVulcan_GPlus2Params 1000000 2039 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_GPlusAll 300000 6603 ns/op 640 B/op 11 allocs/op
|
||||||
|
BenchmarkBear_GPlusAll 100000 22363 ns/op 5488 B/op 61 allocs/op
|
||||||
|
BenchmarkBeego_GPlusAll 50000 38757 ns/op 4784 B/op 52 allocs/op
|
||||||
|
BenchmarkBone_GPlusAll 20000 54916 ns/op 10336 B/op 98 allocs/op
|
||||||
|
BenchmarkDenco_GPlusAll 300000 4959 ns/op 672 B/op 11 allocs/op
|
||||||
|
BenchmarkEcho_GPlusAll 200000 6558 ns/op 416 B/op 13 allocs/op
|
||||||
|
BenchmarkGin_GPlusAll 500000 2757 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_GPlusAll 50000 34615 ns/op 8040 B/op 103 allocs/op
|
||||||
|
BenchmarkGoji_GPlusAll 100000 16002 ns/op 3696 B/op 22 allocs/op
|
||||||
|
BenchmarkGojiv2_GPlusAll 50000 35060 ns/op 12624 B/op 115 allocs/op
|
||||||
|
BenchmarkGoJsonRest_GPlusAll 50000 41479 ns/op 8117 B/op 170 allocs/op
|
||||||
|
BenchmarkGoRestful_GPlusAll 10000 131653 ns/op 32024 B/op 275 allocs/op
|
||||||
|
BenchmarkGorillaMux_GPlusAll 10000 101380 ns/op 13296 B/op 142 allocs/op
|
||||||
|
BenchmarkHttpRouter_GPlusAll 500000 3711 ns/op 640 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_GPlusAll 100000 14438 ns/op 4032 B/op 38 allocs/op
|
||||||
|
BenchmarkKocha_GPlusAll 200000 8039 ns/op 976 B/op 43 allocs/op
|
||||||
|
BenchmarkLARS_GPlusAll 500000 2630 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_GPlusAll 30000 51123 ns/op 13152 B/op 128 allocs/op
|
||||||
|
BenchmarkMartini_GPlusAll 10000 176157 ns/op 14016 B/op 145 allocs/op
|
||||||
|
BenchmarkPat_GPlusAll 20000 69911 ns/op 16576 B/op 298 allocs/op
|
||||||
|
BenchmarkPossum_GPlusAll 100000 20716 ns/op 5408 B/op 39 allocs/op
|
||||||
|
BenchmarkR2router_GPlusAll 100000 17463 ns/op 5040 B/op 63 allocs/op
|
||||||
|
BenchmarkRivet_GPlusAll 300000 5142 ns/op 768 B/op 11 allocs/op
|
||||||
|
BenchmarkTango_GPlusAll 50000 27321 ns/op 3656 B/op 104 allocs/op
|
||||||
|
BenchmarkTigerTonic_GPlusAll 20000 77597 ns/op 14512 B/op 288 allocs/op
|
||||||
|
BenchmarkTraffic_GPlusAll 10000 151406 ns/op 37360 B/op 392 allocs/op
|
||||||
|
BenchmarkVulcan_GPlusAll 100000 18555 ns/op 1274 B/op 39 allocs/op
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parse.com
|
||||||
|
|
||||||
|
```
|
||||||
|
BenchmarkGin_ParseStatic 10000000 133 ns/op 0 B/op 0 allocs/op
|
||||||
|
|
||||||
|
BenchmarkAce_ParseStatic 5000000 241 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkBear_ParseStatic 2000000 728 ns/op 120 B/op 3 allocs/op
|
||||||
|
BenchmarkBeego_ParseStatic 1000000 2623 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_ParseStatic 1000000 1285 ns/op 144 B/op 3 allocs/op
|
||||||
|
BenchmarkDenco_ParseStatic 30000000 57.8 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkEcho_ParseStatic 5000000 342 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGocraftWeb_ParseStatic 1000000 1478 ns/op 296 B/op 5 allocs/op
|
||||||
|
BenchmarkGoji_ParseStatic 3000000 415 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGojiv2_ParseStatic 1000000 2087 ns/op 928 B/op 7 allocs/op
|
||||||
|
BenchmarkGoJsonRest_ParseStatic 1000000 1712 ns/op 329 B/op 11 allocs/op
|
||||||
|
BenchmarkGoRestful_ParseStatic 200000 11072 ns/op 3224 B/op 22 allocs/op
|
||||||
|
BenchmarkGorillaMux_ParseStatic 500000 4129 ns/op 752 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpRouter_ParseStatic 30000000 52.4 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_ParseStatic 20000000 109 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkKocha_ParseStatic 20000000 81.8 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkLARS_ParseStatic 10000000 150 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_ParseStatic 1000000 3288 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkMartini_ParseStatic 200000 9110 ns/op 768 B/op 9 allocs/op
|
||||||
|
BenchmarkPat_ParseStatic 1000000 1135 ns/op 240 B/op 5 allocs/op
|
||||||
|
BenchmarkPossum_ParseStatic 1000000 1557 ns/op 416 B/op 3 allocs/op
|
||||||
|
BenchmarkR2router_ParseStatic 2000000 730 ns/op 144 B/op 4 allocs/op
|
||||||
|
BenchmarkRivet_ParseStatic 10000000 121 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkTango_ParseStatic 1000000 1688 ns/op 248 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_ParseStatic 3000000 427 ns/op 48 B/op 1 allocs/op
|
||||||
|
BenchmarkTraffic_ParseStatic 500000 5962 ns/op 1816 B/op 20 allocs/op
|
||||||
|
BenchmarkVulcan_ParseStatic 2000000 969 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_ParseParam 3000000 497 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkBear_ParseParam 1000000 1473 ns/op 467 B/op 5 allocs/op
|
||||||
|
BenchmarkBeego_ParseParam 1000000 2384 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_ParseParam 1000000 2513 ns/op 768 B/op 6 allocs/op
|
||||||
|
BenchmarkDenco_ParseParam 5000000 364 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkEcho_ParseParam 5000000 418 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGin_ParseParam 10000000 163 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_ParseParam 1000000 2361 ns/op 664 B/op 8 allocs/op
|
||||||
|
BenchmarkGoji_ParseParam 1000000 1590 ns/op 336 B/op 2 allocs/op
|
||||||
|
BenchmarkGojiv2_ParseParam 1000000 2851 ns/op 976 B/op 9 allocs/op
|
||||||
|
BenchmarkGoJsonRest_ParseParam 1000000 2965 ns/op 649 B/op 13 allocs/op
|
||||||
|
BenchmarkGoRestful_ParseParam 200000 12207 ns/op 3544 B/op 23 allocs/op
|
||||||
|
BenchmarkGorillaMux_ParseParam 500000 5187 ns/op 1088 B/op 12 allocs/op
|
||||||
|
BenchmarkHttpRouter_ParseParam 5000000 275 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_ParseParam 1000000 1108 ns/op 352 B/op 3 allocs/op
|
||||||
|
BenchmarkKocha_ParseParam 3000000 495 ns/op 56 B/op 3 allocs/op
|
||||||
|
BenchmarkLARS_ParseParam 10000000 192 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_ParseParam 500000 4103 ns/op 1056 B/op 10 allocs/op
|
||||||
|
BenchmarkMartini_ParseParam 200000 9878 ns/op 1072 B/op 10 allocs/op
|
||||||
|
BenchmarkPat_ParseParam 500000 3657 ns/op 1120 B/op 17 allocs/op
|
||||||
|
BenchmarkPossum_ParseParam 1000000 2084 ns/op 560 B/op 6 allocs/op
|
||||||
|
BenchmarkR2router_ParseParam 1000000 1251 ns/op 432 B/op 5 allocs/op
|
||||||
|
BenchmarkRivet_ParseParam 5000000 335 ns/op 48 B/op 1 allocs/op
|
||||||
|
BenchmarkTango_ParseParam 1000000 1854 ns/op 280 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_ParseParam 500000 4582 ns/op 1008 B/op 17 allocs/op
|
||||||
|
BenchmarkTraffic_ParseParam 200000 8125 ns/op 2248 B/op 23 allocs/op
|
||||||
|
BenchmarkVulcan_ParseParam 1000000 1148 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_Parse2Params 3000000 539 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkBear_Parse2Params 1000000 1778 ns/op 496 B/op 5 allocs/op
|
||||||
|
BenchmarkBeego_Parse2Params 1000000 2519 ns/op 368 B/op 4 allocs/op
|
||||||
|
BenchmarkBone_Parse2Params 1000000 2596 ns/op 720 B/op 5 allocs/op
|
||||||
|
BenchmarkDenco_Parse2Params 3000000 492 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkEcho_Parse2Params 3000000 484 ns/op 32 B/op 1 allocs/op
|
||||||
|
BenchmarkGin_Parse2Params 10000000 193 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_Parse2Params 1000000 2575 ns/op 712 B/op 9 allocs/op
|
||||||
|
BenchmarkGoji_Parse2Params 1000000 1373 ns/op 336 B/op 2 allocs/op
|
||||||
|
BenchmarkGojiv2_Parse2Params 500000 2416 ns/op 960 B/op 8 allocs/op
|
||||||
|
BenchmarkGoJsonRest_Parse2Params 300000 3452 ns/op 713 B/op 14 allocs/op
|
||||||
|
BenchmarkGoRestful_Parse2Params 100000 17719 ns/op 6008 B/op 25 allocs/op
|
||||||
|
BenchmarkGorillaMux_Parse2Params 300000 5102 ns/op 1088 B/op 11 allocs/op
|
||||||
|
BenchmarkHttpRouter_Parse2Params 5000000 303 ns/op 64 B/op 1 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_Parse2Params 1000000 1372 ns/op 384 B/op 4 allocs/op
|
||||||
|
BenchmarkKocha_Parse2Params 2000000 874 ns/op 128 B/op 5 allocs/op
|
||||||
|
BenchmarkLARS_Parse2Params 10000000 192 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_Parse2Params 500000 3871 ns/op 1056 B/op 10 allocs/op
|
||||||
|
BenchmarkMartini_Parse2Params 200000 9954 ns/op 1152 B/op 11 allocs/op
|
||||||
|
BenchmarkPat_Parse2Params 500000 4194 ns/op 832 B/op 17 allocs/op
|
||||||
|
BenchmarkPossum_Parse2Params 1000000 2121 ns/op 560 B/op 6 allocs/op
|
||||||
|
BenchmarkR2router_Parse2Params 1000000 1415 ns/op 432 B/op 5 allocs/op
|
||||||
|
BenchmarkRivet_Parse2Params 3000000 457 ns/op 96 B/op 1 allocs/op
|
||||||
|
BenchmarkTango_Parse2Params 1000000 1914 ns/op 312 B/op 8 allocs/op
|
||||||
|
BenchmarkTigerTonic_Parse2Params 300000 6895 ns/op 1408 B/op 24 allocs/op
|
||||||
|
BenchmarkTraffic_Parse2Params 200000 8317 ns/op 2040 B/op 22 allocs/op
|
||||||
|
BenchmarkVulcan_Parse2Params 1000000 1274 ns/op 98 B/op 3 allocs/op
|
||||||
|
BenchmarkAce_ParseAll 200000 10401 ns/op 640 B/op 16 allocs/op
|
||||||
|
BenchmarkBear_ParseAll 50000 37743 ns/op 8928 B/op 110 allocs/op
|
||||||
|
BenchmarkBeego_ParseAll 20000 63193 ns/op 9568 B/op 104 allocs/op
|
||||||
|
BenchmarkBone_ParseAll 20000 61767 ns/op 14160 B/op 131 allocs/op
|
||||||
|
BenchmarkDenco_ParseAll 300000 7036 ns/op 928 B/op 16 allocs/op
|
||||||
|
BenchmarkEcho_ParseAll 200000 11824 ns/op 832 B/op 26 allocs/op
|
||||||
|
BenchmarkGin_ParseAll 300000 4199 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkGocraftWeb_ParseAll 30000 51758 ns/op 13728 B/op 181 allocs/op
|
||||||
|
BenchmarkGoji_ParseAll 50000 29614 ns/op 5376 B/op 32 allocs/op
|
||||||
|
BenchmarkGojiv2_ParseAll 20000 68676 ns/op 24464 B/op 199 allocs/op
|
||||||
|
BenchmarkGoJsonRest_ParseAll 20000 76135 ns/op 13866 B/op 321 allocs/op
|
||||||
|
BenchmarkGoRestful_ParseAll 5000 389487 ns/op 110928 B/op 600 allocs/op
|
||||||
|
BenchmarkGorillaMux_ParseAll 10000 221250 ns/op 24864 B/op 292 allocs/op
|
||||||
|
BenchmarkHttpRouter_ParseAll 200000 6444 ns/op 640 B/op 16 allocs/op
|
||||||
|
BenchmarkHttpTreeMux_ParseAll 50000 30702 ns/op 5728 B/op 51 allocs/op
|
||||||
|
BenchmarkKocha_ParseAll 200000 13712 ns/op 1112 B/op 54 allocs/op
|
||||||
|
BenchmarkLARS_ParseAll 300000 6925 ns/op 0 B/op 0 allocs/op
|
||||||
|
BenchmarkMacaron_ParseAll 20000 96278 ns/op 24576 B/op 250 allocs/op
|
||||||
|
BenchmarkMartini_ParseAll 5000 271352 ns/op 25072 B/op 253 allocs/op
|
||||||
|
BenchmarkPat_ParseAll 20000 74941 ns/op 17264 B/op 343 allocs/op
|
||||||
|
BenchmarkPossum_ParseAll 50000 39947 ns/op 10816 B/op 78 allocs/op
|
||||||
|
BenchmarkR2router_ParseAll 50000 42479 ns/op 8352 B/op 120 allocs/op
|
||||||
|
BenchmarkRivet_ParseAll 200000 7726 ns/op 912 B/op 16 allocs/op
|
||||||
|
BenchmarkTango_ParseAll 30000 50014 ns/op 7168 B/op 208 allocs/op
|
||||||
|
BenchmarkTigerTonic_ParseAll 10000 106550 ns/op 19728 B/op 379 allocs/op
|
||||||
|
BenchmarkTraffic_ParseAll 10000 216037 ns/op 57776 B/op 642 allocs/op
|
||||||
|
BenchmarkVulcan_ParseAll 50000 34379 ns/op 2548 B/op 78 allocs/op
|
||||||
```
|
```
|
||||||
|
24
vendor/github.com/gin-gonic/gin/CHANGELOG.md
generated
vendored
24
vendor/github.com/gin-gonic/gin/CHANGELOG.md
generated
vendored
@ -1,6 +1,28 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
### Gin 1.2
|
### Gin 1.3.0
|
||||||
|
|
||||||
|
- [NEW] Add [`func (*Context) QueryMap`](https://godoc.org/github.com/gin-gonic/gin#Context.QueryMap), [`func (*Context) GetQueryMap`](https://godoc.org/github.com/gin-gonic/gin#Context.GetQueryMap), [`func (*Context) PostFormMap`](https://godoc.org/github.com/gin-gonic/gin#Context.PostFormMap) and [`func (*Context) GetPostFormMap`](https://godoc.org/github.com/gin-gonic/gin#Context.GetPostFormMap) to support `type map[string]string` as query string or form parameters, see [#1383](https://github.com/gin-gonic/gin/pull/1383)
|
||||||
|
- [NEW] Add [`func (*Context) AsciiJSON`](https://godoc.org/github.com/gin-gonic/gin#Context.AsciiJSON), see [#1358](https://github.com/gin-gonic/gin/pull/1358)
|
||||||
|
- [NEW] Add `Pusher()` in [`type ResponseWriter`](https://godoc.org/github.com/gin-gonic/gin#ResponseWriter) for supporting http2 push, see [#1273](https://github.com/gin-gonic/gin/pull/1273)
|
||||||
|
- [NEW] Add [`func (*Context) DataFromReader`](https://godoc.org/github.com/gin-gonic/gin#Context.DataFromReader) for serving dynamic data, see [#1304](https://github.com/gin-gonic/gin/pull/1304)
|
||||||
|
- [NEW] Add [`func (*Context) ShouldBindBodyWith`](https://godoc.org/github.com/gin-gonic/gin#Context.ShouldBindBodyWith) allowing to call binding multiple times, see [#1341](https://github.com/gin-gonic/gin/pull/1341)
|
||||||
|
- [NEW] Support pointers in form binding, see [#1336](https://github.com/gin-gonic/gin/pull/1336)
|
||||||
|
- [NEW] Add [`func (*Context) JSONP`](https://godoc.org/github.com/gin-gonic/gin#Context.JSONP), see [#1333](https://github.com/gin-gonic/gin/pull/1333)
|
||||||
|
- [NEW] Support default value in form binding, see [#1138](https://github.com/gin-gonic/gin/pull/1138)
|
||||||
|
- [NEW] Expose validator engine in [`type StructValidator`](https://godoc.org/github.com/gin-gonic/gin/binding#StructValidator), see [#1277](https://github.com/gin-gonic/gin/pull/1277)
|
||||||
|
- [NEW] Add [`func (*Context) ShouldBind`](https://godoc.org/github.com/gin-gonic/gin#Context.ShouldBind), [`func (*Context) ShouldBindQuery`](https://godoc.org/github.com/gin-gonic/gin#Context.ShouldBindQuery) and [`func (*Context) ShouldBindJSON`](https://godoc.org/github.com/gin-gonic/gin#Context.ShouldBindJSON), see [#1047](https://github.com/gin-gonic/gin/pull/1047)
|
||||||
|
- [NEW] Add support for `time.Time` location in form binding, see [#1117](https://github.com/gin-gonic/gin/pull/1117)
|
||||||
|
- [NEW] Add [`func (*Context) BindQuery`](https://godoc.org/github.com/gin-gonic/gin#Context.BindQuery), see [#1029](https://github.com/gin-gonic/gin/pull/1029)
|
||||||
|
- [NEW] Make [jsonite](https://github.com/json-iterator/go) optional with build tags, see [#1026](https://github.com/gin-gonic/gin/pull/1026)
|
||||||
|
- [NEW] Show query string in logger, see [#999](https://github.com/gin-gonic/gin/pull/999)
|
||||||
|
- [NEW] Add [`func (*Context) SecureJSON`](https://godoc.org/github.com/gin-gonic/gin#Context.SecureJSON), see [#987](https://github.com/gin-gonic/gin/pull/987) and [#993](https://github.com/gin-gonic/gin/pull/993)
|
||||||
|
- [DEPRECATE] `func (*Context) GetCookie` for [`func (*Context) Cookie`](https://godoc.org/github.com/gin-gonic/gin#Context.Cookie)
|
||||||
|
- [FIX] Don't display color tags if [`func DisableConsoleColor`](https://godoc.org/github.com/gin-gonic/gin#DisableConsoleColor) called, see [#1072](https://github.com/gin-gonic/gin/pull/1072)
|
||||||
|
- [FIX] Gin Mode `""` when calling [`func Mode`](https://godoc.org/github.com/gin-gonic/gin#Mode) now returns `const DebugMode`, see [#1250](https://github.com/gin-gonic/gin/pull/1250)
|
||||||
|
- [FIX] `Flush()` now doesn't overwrite `responseWriter` status code, see [#1460](https://github.com/gin-gonic/gin/pull/1460)
|
||||||
|
|
||||||
|
### Gin 1.2.0
|
||||||
|
|
||||||
- [NEW] Switch from godeps to govendor
|
- [NEW] Switch from godeps to govendor
|
||||||
- [NEW] Add support for Let's Encrypt via gin-gonic/autotls
|
- [NEW] Add support for Let's Encrypt via gin-gonic/autotls
|
||||||
|
46
vendor/github.com/gin-gonic/gin/CODE_OF_CONDUCT.md
generated
vendored
Normal file
46
vendor/github.com/gin-gonic/gin/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at teamgingonic@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
13
vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
generated
vendored
Normal file
13
vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
## Contributing
|
||||||
|
|
||||||
|
- With issues:
|
||||||
|
- Use the search tool before opening a new issue.
|
||||||
|
- Please provide source code and commit sha if you found a bug.
|
||||||
|
- Review existing issues and provide feedback or react to them.
|
||||||
|
|
||||||
|
- With pull requests:
|
||||||
|
- Open your pull request against `master`
|
||||||
|
- Your pull request should have no more than two commits, if not you should squash them.
|
||||||
|
- It should pass all tests in the available continuous integrations systems such as TravisCI.
|
||||||
|
- You should add/modify tests to cover your proposed code changes.
|
||||||
|
- If your pull request contains a new feature, please document it on the README.
|
7
vendor/github.com/gin-gonic/gin/Makefile
generated
vendored
7
vendor/github.com/gin-gonic/gin/Makefile
generated
vendored
@ -1,15 +1,16 @@
|
|||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofmt "-s"
|
||||||
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
|
||||||
|
VETPACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /examples/)
|
||||||
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
|
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
|
||||||
|
|
||||||
all: build
|
all: install
|
||||||
|
|
||||||
install: deps
|
install: deps
|
||||||
govendor sync
|
govendor sync
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
go test -v -covermode=count -coverprofile=coverage.out
|
sh coverage.sh
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
@ -26,7 +27,7 @@ fmt-check:
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
go vet $(PACKAGES)
|
go vet $(VETPACKAGES)
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
@hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
1075
vendor/github.com/gin-gonic/gin/README.md
generated
vendored
1075
vendor/github.com/gin-gonic/gin/README.md
generated
vendored
File diff suppressed because it is too large
Load Diff
46
vendor/github.com/gin-gonic/gin/auth.go
generated
vendored
46
vendor/github.com/gin-gonic/gin/auth.go
generated
vendored
@ -7,27 +7,30 @@ package gin
|
|||||||
import (
|
import (
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AuthUserKey is the cookie name for user credential in basic auth.
|
||||||
const AuthUserKey = "user"
|
const AuthUserKey = "user"
|
||||||
|
|
||||||
type (
|
// Accounts defines a key/value for user/pass list of authorized logins.
|
||||||
Accounts map[string]string
|
type Accounts map[string]string
|
||||||
authPair struct {
|
|
||||||
Value string
|
type authPair struct {
|
||||||
User string
|
value string
|
||||||
}
|
user string
|
||||||
authPairs []authPair
|
}
|
||||||
)
|
|
||||||
|
type authPairs []authPair
|
||||||
|
|
||||||
func (a authPairs) searchCredential(authValue string) (string, bool) {
|
func (a authPairs) searchCredential(authValue string) (string, bool) {
|
||||||
if len(authValue) == 0 {
|
if authValue == "" {
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
for _, pair := range a {
|
for _, pair := range a {
|
||||||
if pair.Value == authValue {
|
if pair.value == authValue {
|
||||||
return pair.User, true
|
return pair.user, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
@ -45,16 +48,17 @@ func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
|
|||||||
pairs := processAccounts(accounts)
|
pairs := processAccounts(accounts)
|
||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
// Search user in the slice of allowed credentials
|
// Search user in the slice of allowed credentials
|
||||||
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
|
user, found := pairs.searchCredential(c.requestHeader("Authorization"))
|
||||||
if !found {
|
if !found {
|
||||||
// Credentials doesn't match, we return 401 and abort handlers chain.
|
// Credentials doesn't match, we return 401 and abort handlers chain.
|
||||||
c.Header("WWW-Authenticate", realm)
|
c.Header("WWW-Authenticate", realm)
|
||||||
c.AbortWithStatus(401)
|
c.AbortWithStatus(http.StatusUnauthorized)
|
||||||
} else {
|
return
|
||||||
// The user credentials was found, set user's id to key AuthUserKey in this context, the userId can be read later using
|
|
||||||
// c.MustGet(gin.AuthUserKey)
|
|
||||||
c.Set(AuthUserKey, user)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using
|
||||||
|
// c.MustGet(gin.AuthUserKey).
|
||||||
|
c.Set(AuthUserKey, user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,11 +72,11 @@ func processAccounts(accounts Accounts) authPairs {
|
|||||||
assert1(len(accounts) > 0, "Empty list of authorized credentials")
|
assert1(len(accounts) > 0, "Empty list of authorized credentials")
|
||||||
pairs := make(authPairs, 0, len(accounts))
|
pairs := make(authPairs, 0, len(accounts))
|
||||||
for user, password := range accounts {
|
for user, password := range accounts {
|
||||||
assert1(len(user) > 0, "User can not be empty")
|
assert1(user != "", "User can not be empty")
|
||||||
value := authorizationHeader(user, password)
|
value := authorizationHeader(user, password)
|
||||||
pairs = append(pairs, authPair{
|
pairs = append(pairs, authPair{
|
||||||
Value: value,
|
value: value,
|
||||||
User: user,
|
user: user,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return pairs
|
return pairs
|
||||||
@ -87,6 +91,6 @@ func secureCompare(given, actual string) bool {
|
|||||||
if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 {
|
if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 {
|
||||||
return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1
|
return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1
|
||||||
}
|
}
|
||||||
/* Securely compare actual to itself to keep constant time, but always return false */
|
// Securely compare actual to itself to keep constant time, but always return false.
|
||||||
return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false
|
return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false
|
||||||
}
|
}
|
||||||
|
38
vendor/github.com/gin-gonic/gin/auth_test.go
generated
vendored
38
vendor/github.com/gin-gonic/gin/auth_test.go
generated
vendored
@ -22,16 +22,16 @@ func TestBasicAuth(t *testing.T) {
|
|||||||
|
|
||||||
assert.Len(t, pairs, 3)
|
assert.Len(t, pairs, 3)
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "bar",
|
user: "bar",
|
||||||
Value: "Basic YmFyOmZvbw==",
|
value: "Basic YmFyOmZvbw==",
|
||||||
})
|
})
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "foo",
|
user: "foo",
|
||||||
Value: "Basic Zm9vOmJhcg==",
|
value: "Basic Zm9vOmJhcg==",
|
||||||
})
|
})
|
||||||
assert.Contains(t, pairs, authPair{
|
assert.Contains(t, pairs, authPair{
|
||||||
User: "admin",
|
user: "admin",
|
||||||
Value: "Basic YWRtaW46cGFzc3dvcmQ=",
|
value: "Basic YWRtaW46cGFzc3dvcmQ=",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,15 +53,15 @@ func TestBasicAuthSearchCredential(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
user, found := pairs.searchCredential(authorizationHeader("admin", "password"))
|
user, found := pairs.searchCredential(authorizationHeader("admin", "password"))
|
||||||
assert.Equal(t, user, "admin")
|
assert.Equal(t, "admin", user)
|
||||||
assert.True(t, found)
|
assert.True(t, found)
|
||||||
|
|
||||||
user, found = pairs.searchCredential(authorizationHeader("foo", "bar"))
|
user, found = pairs.searchCredential(authorizationHeader("foo", "bar"))
|
||||||
assert.Equal(t, user, "foo")
|
assert.Equal(t, "foo", user)
|
||||||
assert.True(t, found)
|
assert.True(t, found)
|
||||||
|
|
||||||
user, found = pairs.searchCredential(authorizationHeader("bar", "foo"))
|
user, found = pairs.searchCredential(authorizationHeader("bar", "foo"))
|
||||||
assert.Equal(t, user, "bar")
|
assert.Equal(t, "bar", user)
|
||||||
assert.True(t, found)
|
assert.True(t, found)
|
||||||
|
|
||||||
user, found = pairs.searchCredential(authorizationHeader("admins", "password"))
|
user, found = pairs.searchCredential(authorizationHeader("admins", "password"))
|
||||||
@ -78,7 +78,7 @@ func TestBasicAuthSearchCredential(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicAuthAuthorizationHeader(t *testing.T) {
|
func TestBasicAuthAuthorizationHeader(t *testing.T) {
|
||||||
assert.Equal(t, authorizationHeader("admin", "password"), "Basic YWRtaW46cGFzc3dvcmQ=")
|
assert.Equal(t, "Basic YWRtaW46cGFzc3dvcmQ=", authorizationHeader("admin", "password"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicAuthSecureCompare(t *testing.T) {
|
func TestBasicAuthSecureCompare(t *testing.T) {
|
||||||
@ -93,7 +93,7 @@ func TestBasicAuthSucceed(t *testing.T) {
|
|||||||
router := New()
|
router := New()
|
||||||
router.Use(BasicAuth(accounts))
|
router.Use(BasicAuth(accounts))
|
||||||
router.GET("/login", func(c *Context) {
|
router.GET("/login", func(c *Context) {
|
||||||
c.String(200, c.MustGet(AuthUserKey).(string))
|
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
|
||||||
})
|
})
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
@ -101,8 +101,8 @@ func TestBasicAuthSucceed(t *testing.T) {
|
|||||||
req.Header.Set("Authorization", authorizationHeader("admin", "password"))
|
req.Header.Set("Authorization", authorizationHeader("admin", "password"))
|
||||||
router.ServeHTTP(w, req)
|
router.ServeHTTP(w, req)
|
||||||
|
|
||||||
assert.Equal(t, w.Code, 200)
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
assert.Equal(t, w.Body.String(), "admin")
|
assert.Equal(t, "admin", w.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicAuth401(t *testing.T) {
|
func TestBasicAuth401(t *testing.T) {
|
||||||
@ -112,7 +112,7 @@ func TestBasicAuth401(t *testing.T) {
|
|||||||
router.Use(BasicAuth(accounts))
|
router.Use(BasicAuth(accounts))
|
||||||
router.GET("/login", func(c *Context) {
|
router.GET("/login", func(c *Context) {
|
||||||
called = true
|
called = true
|
||||||
c.String(200, c.MustGet(AuthUserKey).(string))
|
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
|
||||||
})
|
})
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
@ -121,8 +121,8 @@ func TestBasicAuth401(t *testing.T) {
|
|||||||
router.ServeHTTP(w, req)
|
router.ServeHTTP(w, req)
|
||||||
|
|
||||||
assert.False(t, called)
|
assert.False(t, called)
|
||||||
assert.Equal(t, w.Code, 401)
|
assert.Equal(t, http.StatusUnauthorized, w.Code)
|
||||||
assert.Equal(t, w.HeaderMap.Get("WWW-Authenticate"), "Basic realm=\"Authorization Required\"")
|
assert.Equal(t, "Basic realm=\"Authorization Required\"", w.HeaderMap.Get("WWW-Authenticate"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
||||||
@ -132,7 +132,7 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
|||||||
router.Use(BasicAuthForRealm(accounts, "My Custom \"Realm\""))
|
router.Use(BasicAuthForRealm(accounts, "My Custom \"Realm\""))
|
||||||
router.GET("/login", func(c *Context) {
|
router.GET("/login", func(c *Context) {
|
||||||
called = true
|
called = true
|
||||||
c.String(200, c.MustGet(AuthUserKey).(string))
|
c.String(http.StatusOK, c.MustGet(AuthUserKey).(string))
|
||||||
})
|
})
|
||||||
|
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
@ -141,6 +141,6 @@ func TestBasicAuth401WithCustomRealm(t *testing.T) {
|
|||||||
router.ServeHTTP(w, req)
|
router.ServeHTTP(w, req)
|
||||||
|
|
||||||
assert.False(t, called)
|
assert.False(t, called)
|
||||||
assert.Equal(t, w.Code, 401)
|
assert.Equal(t, http.StatusUnauthorized, w.Code)
|
||||||
assert.Equal(t, w.HeaderMap.Get("WWW-Authenticate"), "Basic realm=\"My Custom \\\"Realm\\\"\"")
|
assert.Equal(t, "Basic realm=\"My Custom \\\"Realm\\\"\"", w.HeaderMap.Get("WWW-Authenticate"))
|
||||||
}
|
}
|
||||||
|
8
vendor/github.com/gin-gonic/gin/benchmarks_test.go
generated
vendored
8
vendor/github.com/gin-gonic/gin/benchmarks_test.go
generated
vendored
@ -54,13 +54,11 @@ func BenchmarkOneRouteJSON(B *testing.B) {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
}{"ok"}
|
}{"ok"}
|
||||||
router.GET("/json", func(c *Context) {
|
router.GET("/json", func(c *Context) {
|
||||||
c.JSON(200, data)
|
c.JSON(http.StatusOK, data)
|
||||||
})
|
})
|
||||||
runRequest(B, router, "GET", "/json")
|
runRequest(B, router, "GET", "/json")
|
||||||
}
|
}
|
||||||
|
|
||||||
var htmlContentType = []string{"text/html; charset=utf-8"}
|
|
||||||
|
|
||||||
func BenchmarkOneRouteHTML(B *testing.B) {
|
func BenchmarkOneRouteHTML(B *testing.B) {
|
||||||
router := New()
|
router := New()
|
||||||
t := template.Must(template.New("index").Parse(`
|
t := template.Must(template.New("index").Parse(`
|
||||||
@ -68,7 +66,7 @@ func BenchmarkOneRouteHTML(B *testing.B) {
|
|||||||
router.SetHTMLTemplate(t)
|
router.SetHTMLTemplate(t)
|
||||||
|
|
||||||
router.GET("/html", func(c *Context) {
|
router.GET("/html", func(c *Context) {
|
||||||
c.HTML(200, "index", "hola")
|
c.HTML(http.StatusOK, "index", "hola")
|
||||||
})
|
})
|
||||||
runRequest(B, router, "GET", "/html")
|
runRequest(B, router, "GET", "/html")
|
||||||
}
|
}
|
||||||
@ -84,7 +82,7 @@ func BenchmarkOneRouteSet(B *testing.B) {
|
|||||||
func BenchmarkOneRouteString(B *testing.B) {
|
func BenchmarkOneRouteString(B *testing.B) {
|
||||||
router := New()
|
router := New()
|
||||||
router.GET("/text", func(c *Context) {
|
router.GET("/text", func(c *Context) {
|
||||||
c.String(200, "this is a plain text")
|
c.String(http.StatusOK, "this is a plain text")
|
||||||
})
|
})
|
||||||
runRequest(B, router, "GET", "/text")
|
runRequest(B, router, "GET", "/text")
|
||||||
}
|
}
|
||||||
|
27
vendor/github.com/gin-gonic/gin/binding/binding.go
generated
vendored
27
vendor/github.com/gin-gonic/gin/binding/binding.go
generated
vendored
@ -6,6 +6,7 @@ package binding
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
// Content-Type MIME of the most common data formats.
|
||||||
const (
|
const (
|
||||||
MIMEJSON = "application/json"
|
MIMEJSON = "application/json"
|
||||||
MIMEHTML = "text/html"
|
MIMEHTML = "text/html"
|
||||||
@ -19,11 +20,25 @@ const (
|
|||||||
MIMEMSGPACK2 = "application/msgpack"
|
MIMEMSGPACK2 = "application/msgpack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Binding describes the interface which needs to be implemented for binding the
|
||||||
|
// data present in the request such as JSON request body, query parameters or
|
||||||
|
// the form POST.
|
||||||
type Binding interface {
|
type Binding interface {
|
||||||
Name() string
|
Name() string
|
||||||
Bind(*http.Request, interface{}) error
|
Bind(*http.Request, interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BindingBody adds BindBody method to Binding. BindBody is similar with Bind,
|
||||||
|
// but it reads the body from supplied bytes instead of req.Body.
|
||||||
|
type BindingBody interface {
|
||||||
|
Binding
|
||||||
|
BindBody([]byte, interface{}) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// StructValidator is the minimal interface which needs to be implemented in
|
||||||
|
// order for it to be used as the validator engine for ensuring the correctness
|
||||||
|
// of the reqest. Gin provides a default implementation for this using
|
||||||
|
// https://github.com/go-playground/validator/tree/v8.18.2.
|
||||||
type StructValidator interface {
|
type StructValidator interface {
|
||||||
// ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right.
|
// ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right.
|
||||||
// If the received type is not a struct, any validation should be skipped and nil must be returned.
|
// If the received type is not a struct, any validation should be skipped and nil must be returned.
|
||||||
@ -31,20 +46,32 @@ type StructValidator interface {
|
|||||||
// If the struct is not valid or the validation itself fails, a descriptive error should be returned.
|
// If the struct is not valid or the validation itself fails, a descriptive error should be returned.
|
||||||
// Otherwise nil must be returned.
|
// Otherwise nil must be returned.
|
||||||
ValidateStruct(interface{}) error
|
ValidateStruct(interface{}) error
|
||||||
|
|
||||||
|
// Engine returns the underlying validator engine which powers the
|
||||||
|
// StructValidator implementation.
|
||||||
|
Engine() interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validator is the default validator which implements the StructValidator
|
||||||
|
// interface. It uses https://github.com/go-playground/validator/tree/v8.18.2
|
||||||
|
// under the hood.
|
||||||
var Validator StructValidator = &defaultValidator{}
|
var Validator StructValidator = &defaultValidator{}
|
||||||
|
|
||||||
|
// These implement the Binding interface and can be used to bind the data
|
||||||
|
// present in the request to struct instances.
|
||||||
var (
|
var (
|
||||||
JSON = jsonBinding{}
|
JSON = jsonBinding{}
|
||||||
XML = xmlBinding{}
|
XML = xmlBinding{}
|
||||||
Form = formBinding{}
|
Form = formBinding{}
|
||||||
|
Query = queryBinding{}
|
||||||
FormPost = formPostBinding{}
|
FormPost = formPostBinding{}
|
||||||
FormMultipart = formMultipartBinding{}
|
FormMultipart = formMultipartBinding{}
|
||||||
ProtoBuf = protobufBinding{}
|
ProtoBuf = protobufBinding{}
|
||||||
MsgPack = msgpackBinding{}
|
MsgPack = msgpackBinding{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Default returns the appropriate Binding instance based on the HTTP method
|
||||||
|
// and the content type.
|
||||||
func Default(method, contentType string) Binding {
|
func Default(method, contentType string) Binding {
|
||||||
if method == "GET" {
|
if method == "GET" {
|
||||||
return Form
|
return Form
|
||||||
|
67
vendor/github.com/gin-gonic/gin/binding/binding_body_test.go
generated
vendored
Normal file
67
vendor/github.com/gin-gonic/gin/binding/binding_body_test.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package binding
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io/ioutil"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/testdata/protoexample"
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/ugorji/go/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBindingBody(t *testing.T) {
|
||||||
|
for _, tt := range []struct {
|
||||||
|
name string
|
||||||
|
binding BindingBody
|
||||||
|
body string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "JSON bidning",
|
||||||
|
binding: JSON,
|
||||||
|
body: `{"foo":"FOO"}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "XML bidning",
|
||||||
|
binding: XML,
|
||||||
|
body: `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<root>
|
||||||
|
<foo>FOO</foo>
|
||||||
|
</root>`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MsgPack binding",
|
||||||
|
binding: MsgPack,
|
||||||
|
body: msgPackBody(t),
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Logf("testing: %s", tt.name)
|
||||||
|
req := requestWithBody("POST", "/", tt.body)
|
||||||
|
form := FooStruct{}
|
||||||
|
body, _ := ioutil.ReadAll(req.Body)
|
||||||
|
assert.NoError(t, tt.binding.BindBody(body, &form))
|
||||||
|
assert.Equal(t, FooStruct{"FOO"}, form)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func msgPackBody(t *testing.T) string {
|
||||||
|
test := FooStruct{"FOO"}
|
||||||
|
h := new(codec.MsgpackHandle)
|
||||||
|
buf := bytes.NewBuffer(nil)
|
||||||
|
assert.NoError(t, codec.NewEncoder(buf, h).Encode(test))
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBindingBodyProto(t *testing.T) {
|
||||||
|
test := protoexample.Test{
|
||||||
|
Label: proto.String("FOO"),
|
||||||
|
}
|
||||||
|
data, _ := proto.Marshal(&test)
|
||||||
|
req := requestWithBody("POST", "/", string(data))
|
||||||
|
form := protoexample.Test{}
|
||||||
|
body, _ := ioutil.ReadAll(req.Body)
|
||||||
|
assert.NoError(t, ProtoBuf.BindBody(body, &form))
|
||||||
|
assert.Equal(t, test, form)
|
||||||
|
}
|
1020
vendor/github.com/gin-gonic/gin/binding/binding_test.go
generated
vendored
1020
vendor/github.com/gin-gonic/gin/binding/binding_test.go
generated
vendored
File diff suppressed because it is too large
Load Diff
28
vendor/github.com/gin-gonic/gin/binding/default_validator.go
generated
vendored
28
vendor/github.com/gin-gonic/gin/binding/default_validator.go
generated
vendored
@ -18,28 +18,34 @@ type defaultValidator struct {
|
|||||||
|
|
||||||
var _ StructValidator = &defaultValidator{}
|
var _ StructValidator = &defaultValidator{}
|
||||||
|
|
||||||
|
// ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.
|
||||||
func (v *defaultValidator) ValidateStruct(obj interface{}) error {
|
func (v *defaultValidator) ValidateStruct(obj interface{}) error {
|
||||||
if kindOfData(obj) == reflect.Struct {
|
value := reflect.ValueOf(obj)
|
||||||
|
valueType := value.Kind()
|
||||||
|
if valueType == reflect.Ptr {
|
||||||
|
valueType = value.Elem().Kind()
|
||||||
|
}
|
||||||
|
if valueType == reflect.Struct {
|
||||||
v.lazyinit()
|
v.lazyinit()
|
||||||
if err := v.validate.Struct(obj); err != nil {
|
if err := v.validate.Struct(obj); err != nil {
|
||||||
return error(err)
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Engine returns the underlying validator engine which powers the default
|
||||||
|
// Validator instance. This is useful if you want to register custom validations
|
||||||
|
// or struct level validations. See validator GoDoc for more info -
|
||||||
|
// https://godoc.org/gopkg.in/go-playground/validator.v8
|
||||||
|
func (v *defaultValidator) Engine() interface{} {
|
||||||
|
v.lazyinit()
|
||||||
|
return v.validate
|
||||||
|
}
|
||||||
|
|
||||||
func (v *defaultValidator) lazyinit() {
|
func (v *defaultValidator) lazyinit() {
|
||||||
v.once.Do(func() {
|
v.once.Do(func() {
|
||||||
config := &validator.Config{TagName: "binding"}
|
config := &validator.Config{TagName: "binding"}
|
||||||
v.validate = validator.New(config)
|
v.validate = validator.New(config)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func kindOfData(data interface{}) reflect.Kind {
|
|
||||||
value := reflect.ValueOf(data)
|
|
||||||
valueType := value.Kind()
|
|
||||||
if valueType == reflect.Ptr {
|
|
||||||
valueType = value.Elem().Kind()
|
|
||||||
}
|
|
||||||
return valueType
|
|
||||||
}
|
|
||||||
|
6
vendor/github.com/gin-gonic/gin/binding/form.go
generated
vendored
6
vendor/github.com/gin-gonic/gin/binding/form.go
generated
vendored
@ -6,6 +6,8 @@ package binding
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
const defaultMemory = 32 * 1024 * 1024
|
||||||
|
|
||||||
type formBinding struct{}
|
type formBinding struct{}
|
||||||
type formPostBinding struct{}
|
type formPostBinding struct{}
|
||||||
type formMultipartBinding struct{}
|
type formMultipartBinding struct{}
|
||||||
@ -18,7 +20,7 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
|
|||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.ParseMultipartForm(32 << 10) // 32 MB
|
req.ParseMultipartForm(defaultMemory)
|
||||||
if err := mapForm(obj, req.Form); err != nil {
|
if err := mapForm(obj, req.Form); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -44,7 +46,7 @@ func (formMultipartBinding) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
|
func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
if err := req.ParseMultipartForm(32 << 10); err != nil {
|
if err := req.ParseMultipartForm(defaultMemory); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := mapForm(obj, req.MultipartForm.Value); err != nil {
|
if err := mapForm(obj, req.MultipartForm.Value); err != nil {
|
||||||
|
51
vendor/github.com/gin-gonic/gin/binding/form_mapping.go
generated
vendored
51
vendor/github.com/gin-gonic/gin/binding/form_mapping.go
generated
vendored
@ -8,6 +8,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,12 +24,28 @@ func mapForm(ptr interface{}, form map[string][]string) error {
|
|||||||
|
|
||||||
structFieldKind := structField.Kind()
|
structFieldKind := structField.Kind()
|
||||||
inputFieldName := typeField.Tag.Get("form")
|
inputFieldName := typeField.Tag.Get("form")
|
||||||
|
inputFieldNameList := strings.Split(inputFieldName, ",")
|
||||||
|
inputFieldName = inputFieldNameList[0]
|
||||||
|
var defaultValue string
|
||||||
|
if len(inputFieldNameList) > 1 {
|
||||||
|
defaultList := strings.SplitN(inputFieldNameList[1], "=", 2)
|
||||||
|
if defaultList[0] == "default" {
|
||||||
|
defaultValue = defaultList[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
if inputFieldName == "" {
|
if inputFieldName == "" {
|
||||||
inputFieldName = typeField.Name
|
inputFieldName = typeField.Name
|
||||||
|
|
||||||
// if "form" tag is nil, we inspect if the field is a struct.
|
// if "form" tag is nil, we inspect if the field is a struct or struct pointer.
|
||||||
// this would not make sense for JSON parsing but it does for a form
|
// this would not make sense for JSON parsing but it does for a form
|
||||||
// since data is flatten
|
// since data is flatten
|
||||||
|
if structFieldKind == reflect.Ptr {
|
||||||
|
if !structField.Elem().IsValid() {
|
||||||
|
structField.Set(reflect.New(structField.Type().Elem()))
|
||||||
|
}
|
||||||
|
structField = structField.Elem()
|
||||||
|
structFieldKind = structField.Kind()
|
||||||
|
}
|
||||||
if structFieldKind == reflect.Struct {
|
if structFieldKind == reflect.Struct {
|
||||||
err := mapForm(structField.Addr().Interface(), form)
|
err := mapForm(structField.Addr().Interface(), form)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -38,8 +55,13 @@ func mapForm(ptr interface{}, form map[string][]string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputValue, exists := form[inputFieldName]
|
inputValue, exists := form[inputFieldName]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
continue
|
if defaultValue == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
inputValue = make([]string, 1)
|
||||||
|
inputValue[0] = defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
numElems := len(inputValue)
|
numElems := len(inputValue)
|
||||||
@ -97,6 +119,12 @@ func setWithProperType(valueKind reflect.Kind, val string, structField reflect.V
|
|||||||
return setFloatField(val, 64, structField)
|
return setFloatField(val, 64, structField)
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
structField.SetString(val)
|
structField.SetString(val)
|
||||||
|
case reflect.Ptr:
|
||||||
|
if !structField.Elem().IsValid() {
|
||||||
|
structField.Set(reflect.New(structField.Type().Elem()))
|
||||||
|
}
|
||||||
|
structFieldElem := structField.Elem()
|
||||||
|
return setWithProperType(structFieldElem.Kind(), val, structFieldElem)
|
||||||
default:
|
default:
|
||||||
return errors.New("Unknown type")
|
return errors.New("Unknown type")
|
||||||
}
|
}
|
||||||
@ -133,7 +161,7 @@ func setBoolField(val string, field reflect.Value) error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
field.SetBool(boolVal)
|
field.SetBool(boolVal)
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFloatField(val string, bitSize int, field reflect.Value) error {
|
func setFloatField(val string, bitSize int, field reflect.Value) error {
|
||||||
@ -163,6 +191,14 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
|
|||||||
l = time.UTC
|
l = time.UTC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if locTag := structField.Tag.Get("time_location"); locTag != "" {
|
||||||
|
loc, err := time.LoadLocation(locTag)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
l = loc
|
||||||
|
}
|
||||||
|
|
||||||
t, err := time.ParseInLocation(timeFormat, val, l)
|
t, err := time.ParseInLocation(timeFormat, val, l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -171,12 +207,3 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
|
|||||||
value.Set(reflect.ValueOf(t))
|
value.Set(reflect.ValueOf(t))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't pass in pointers to bind to. Can lead to bugs. See:
|
|
||||||
// https://github.com/codegangsta/martini-contrib/issues/40
|
|
||||||
// https://github.com/codegangsta/martini-contrib/pull/34#issuecomment-29683659
|
|
||||||
func ensureNotPointer(obj interface{}) {
|
|
||||||
if reflect.TypeOf(obj).Kind() == reflect.Ptr {
|
|
||||||
panic("Pointers are not accepted as binding models")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
23
vendor/github.com/gin-gonic/gin/binding/json.go
generated
vendored
23
vendor/github.com/gin-gonic/gin/binding/json.go
generated
vendored
@ -5,10 +5,18 @@
|
|||||||
package binding
|
package binding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"bytes"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// EnableDecoderUseNumber is used to call the UseNumber method on the JSON
|
||||||
|
// Decoder instance. UseNumber causes the Decoder to unmarshal a number into an
|
||||||
|
// interface{} as a Number instead of as a float64.
|
||||||
|
var EnableDecoderUseNumber = false
|
||||||
|
|
||||||
type jsonBinding struct{}
|
type jsonBinding struct{}
|
||||||
|
|
||||||
func (jsonBinding) Name() string {
|
func (jsonBinding) Name() string {
|
||||||
@ -16,7 +24,18 @@ func (jsonBinding) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
|
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
decoder := json.NewDecoder(req.Body)
|
return decodeJSON(req.Body, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jsonBinding) BindBody(body []byte, obj interface{}) error {
|
||||||
|
return decodeJSON(bytes.NewReader(body), obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeJSON(r io.Reader, obj interface{}) error {
|
||||||
|
decoder := json.NewDecoder(r)
|
||||||
|
if EnableDecoderUseNumber {
|
||||||
|
decoder.UseNumber()
|
||||||
|
}
|
||||||
if err := decoder.Decode(obj); err != nil {
|
if err := decoder.Decode(obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
15
vendor/github.com/gin-gonic/gin/binding/msgpack.go
generated
vendored
15
vendor/github.com/gin-gonic/gin/binding/msgpack.go
generated
vendored
@ -5,6 +5,8 @@
|
|||||||
package binding
|
package binding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/ugorji/go/codec"
|
"github.com/ugorji/go/codec"
|
||||||
@ -17,12 +19,17 @@ func (msgpackBinding) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (msgpackBinding) Bind(req *http.Request, obj interface{}) error {
|
func (msgpackBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
|
return decodeMsgPack(req.Body, obj)
|
||||||
|
}
|
||||||
|
|
||||||
if err := codec.NewDecoder(req.Body, new(codec.MsgpackHandle)).Decode(&obj); err != nil {
|
func (msgpackBinding) BindBody(body []byte, obj interface{}) error {
|
||||||
//var decoder *codec.Decoder = codec.NewDecoder(req.Body, &codec.MsgpackHandle)
|
return decodeMsgPack(bytes.NewReader(body), obj)
|
||||||
//if err := decoder.Decode(&obj); err != nil {
|
}
|
||||||
|
|
||||||
|
func decodeMsgPack(r io.Reader, obj interface{}) error {
|
||||||
|
cdc := new(codec.MsgpackHandle)
|
||||||
|
if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return validate(obj)
|
return validate(obj)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
15
vendor/github.com/gin-gonic/gin/binding/protobuf.go
generated
vendored
15
vendor/github.com/gin-gonic/gin/binding/protobuf.go
generated
vendored
@ -17,19 +17,20 @@ func (protobufBinding) Name() string {
|
|||||||
return "protobuf"
|
return "protobuf"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (protobufBinding) Bind(req *http.Request, obj interface{}) error {
|
func (b protobufBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(req.Body)
|
buf, err := ioutil.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return b.BindBody(buf, obj)
|
||||||
|
}
|
||||||
|
|
||||||
if err = proto.Unmarshal(buf, obj.(proto.Message)); err != nil {
|
func (protobufBinding) BindBody(body []byte, obj interface{}) error {
|
||||||
|
if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Here it's same to return validate(obj), but util now we cann't add
|
||||||
//Here it's same to return validate(obj), but util now we cann't add `binding:""` to the struct
|
// `binding:""` to the struct which automatically generate by gen-proto
|
||||||
//which automatically generate by gen-proto
|
|
||||||
return nil
|
return nil
|
||||||
//return validate(obj)
|
// return validate(obj)
|
||||||
}
|
}
|
||||||
|
21
vendor/github.com/gin-gonic/gin/binding/query.go
generated
vendored
Normal file
21
vendor/github.com/gin-gonic/gin/binding/query.go
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package binding
|
||||||
|
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
|
type queryBinding struct{}
|
||||||
|
|
||||||
|
func (queryBinding) Name() string {
|
||||||
|
return "query"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (queryBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
|
values := req.URL.Query()
|
||||||
|
if err := mapForm(obj, values); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return validate(obj)
|
||||||
|
}
|
50
vendor/github.com/gin-gonic/gin/binding/validate_test.go
generated
vendored
50
vendor/github.com/gin-gonic/gin/binding/validate_test.go
generated
vendored
@ -6,10 +6,12 @@ package binding
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"gopkg.in/go-playground/validator.v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testInterface interface {
|
type testInterface interface {
|
||||||
@ -174,7 +176,7 @@ func TestValidatePrimitives(t *testing.T) {
|
|||||||
obj := Object{"foo": "bar", "bar": 1}
|
obj := Object{"foo": "bar", "bar": 1}
|
||||||
assert.NoError(t, validate(obj))
|
assert.NoError(t, validate(obj))
|
||||||
assert.NoError(t, validate(&obj))
|
assert.NoError(t, validate(&obj))
|
||||||
assert.Equal(t, obj, Object{"foo": "bar", "bar": 1})
|
assert.Equal(t, Object{"foo": "bar", "bar": 1}, obj)
|
||||||
|
|
||||||
obj2 := []Object{{"foo": "bar", "bar": 1}, {"foo": "bar", "bar": 1}}
|
obj2 := []Object{{"foo": "bar", "bar": 1}, {"foo": "bar", "bar": 1}}
|
||||||
assert.NoError(t, validate(obj2))
|
assert.NoError(t, validate(obj2))
|
||||||
@ -183,10 +185,52 @@ func TestValidatePrimitives(t *testing.T) {
|
|||||||
nu := 10
|
nu := 10
|
||||||
assert.NoError(t, validate(nu))
|
assert.NoError(t, validate(nu))
|
||||||
assert.NoError(t, validate(&nu))
|
assert.NoError(t, validate(&nu))
|
||||||
assert.Equal(t, nu, 10)
|
assert.Equal(t, 10, nu)
|
||||||
|
|
||||||
str := "value"
|
str := "value"
|
||||||
assert.NoError(t, validate(str))
|
assert.NoError(t, validate(str))
|
||||||
assert.NoError(t, validate(&str))
|
assert.NoError(t, validate(&str))
|
||||||
assert.Equal(t, str, "value")
|
assert.Equal(t, "value", str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// structCustomValidation is a helper struct we use to check that
|
||||||
|
// custom validation can be registered on it.
|
||||||
|
// The `notone` binding directive is for custom validation and registered later.
|
||||||
|
type structCustomValidation struct {
|
||||||
|
Integer int `binding:"notone"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// notOne is a custom validator meant to be used with `validator.v8` library.
|
||||||
|
// The method signature for `v9` is significantly different and this function
|
||||||
|
// would need to be changed for tests to pass after upgrade.
|
||||||
|
// See https://github.com/gin-gonic/gin/pull/1015.
|
||||||
|
func notOne(
|
||||||
|
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
|
||||||
|
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
|
||||||
|
) bool {
|
||||||
|
if val, ok := field.Interface().(int); ok {
|
||||||
|
return val != 1
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidatorEngine(t *testing.T) {
|
||||||
|
// This validates that the function `notOne` matches
|
||||||
|
// the expected function signature by `defaultValidator`
|
||||||
|
// and by extension the validator library.
|
||||||
|
engine, ok := Validator.Engine().(*validator.Validate)
|
||||||
|
assert.True(t, ok)
|
||||||
|
|
||||||
|
err := engine.RegisterValidation("notone", notOne)
|
||||||
|
// Check that we can register custom validation without error
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
// Create an instance which will fail validation
|
||||||
|
withOne := structCustomValidation{Integer: 1}
|
||||||
|
errs := validate(withOne)
|
||||||
|
|
||||||
|
// Check that we got back non-nil errs
|
||||||
|
assert.NotNil(t, errs)
|
||||||
|
// Check that the error matches expectation
|
||||||
|
assert.Error(t, errs, "", "", "notone")
|
||||||
}
|
}
|
||||||
|
11
vendor/github.com/gin-gonic/gin/binding/xml.go
generated
vendored
11
vendor/github.com/gin-gonic/gin/binding/xml.go
generated
vendored
@ -5,7 +5,9 @@
|
|||||||
package binding
|
package binding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +18,14 @@ func (xmlBinding) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (xmlBinding) Bind(req *http.Request, obj interface{}) error {
|
func (xmlBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
decoder := xml.NewDecoder(req.Body)
|
return decodeXML(req.Body, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (xmlBinding) BindBody(body []byte, obj interface{}) error {
|
||||||
|
return decodeXML(bytes.NewReader(body), obj)
|
||||||
|
}
|
||||||
|
func decodeXML(r io.Reader, obj interface{}) error {
|
||||||
|
decoder := xml.NewDecoder(r)
|
||||||
if err := decoder.Decode(obj); err != nil {
|
if err := decoder.Decode(obj); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
343
vendor/github.com/gin-gonic/gin/context.go
generated
vendored
343
vendor/github.com/gin-gonic/gin/context.go
generated
vendored
@ -13,6 +13,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin/render"
|
"github.com/gin-gonic/gin/render"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Content-Type MIME of the most common data formats
|
// Content-Type MIME of the most common data formats.
|
||||||
const (
|
const (
|
||||||
MIMEJSON = binding.MIMEJSON
|
MIMEJSON = binding.MIMEJSON
|
||||||
MIMEHTML = binding.MIMEHTML
|
MIMEHTML = binding.MIMEHTML
|
||||||
@ -30,12 +31,10 @@ const (
|
|||||||
MIMEPlain = binding.MIMEPlain
|
MIMEPlain = binding.MIMEPlain
|
||||||
MIMEPOSTForm = binding.MIMEPOSTForm
|
MIMEPOSTForm = binding.MIMEPOSTForm
|
||||||
MIMEMultipartPOSTForm = binding.MIMEMultipartPOSTForm
|
MIMEMultipartPOSTForm = binding.MIMEMultipartPOSTForm
|
||||||
|
BodyBytesKey = "_gin-gonic/gin/bodybyteskey"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const abortIndex int8 = math.MaxInt8 / 2
|
||||||
defaultMemory = 32 << 20 // 32 MB
|
|
||||||
abortIndex int8 = math.MaxInt8 / 2
|
|
||||||
)
|
|
||||||
|
|
||||||
// Context is the most important part of gin. It allows us to pass variables between middleware,
|
// Context is the most important part of gin. It allows us to pass variables between middleware,
|
||||||
// manage the flow, validate the JSON of a request and render a JSON response for example.
|
// manage the flow, validate the JSON of a request and render a JSON response for example.
|
||||||
@ -48,9 +47,15 @@ type Context struct {
|
|||||||
handlers HandlersChain
|
handlers HandlersChain
|
||||||
index int8
|
index int8
|
||||||
|
|
||||||
engine *Engine
|
engine *Engine
|
||||||
Keys map[string]interface{}
|
|
||||||
Errors errorMsgs
|
// Keys is a key/value pair exclusively for the context of each request.
|
||||||
|
Keys map[string]interface{}
|
||||||
|
|
||||||
|
// Errors is a list of errors attached to all the handlers/middlewares who used this context.
|
||||||
|
Errors errorMsgs
|
||||||
|
|
||||||
|
// Accepted defines a list of manually accepted formats for content negotiation.
|
||||||
Accepted []string
|
Accepted []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +84,8 @@ func (c *Context) Copy() *Context {
|
|||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()", this
|
// HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()",
|
||||||
// function will return "main.handleGetUsers"
|
// this function will return "main.handleGetUsers".
|
||||||
func (c *Context) HandlerName() string {
|
func (c *Context) HandlerName() string {
|
||||||
return nameOfFunction(c.handlers.Last())
|
return nameOfFunction(c.handlers.Last())
|
||||||
}
|
}
|
||||||
@ -99,8 +104,7 @@ func (c *Context) Handler() HandlerFunc {
|
|||||||
// See example in GitHub.
|
// See example in GitHub.
|
||||||
func (c *Context) Next() {
|
func (c *Context) Next() {
|
||||||
c.index++
|
c.index++
|
||||||
s := int8(len(c.handlers))
|
for s := int8(len(c.handlers)); c.index < s; c.index++ {
|
||||||
for ; c.index < s; c.index++ {
|
|
||||||
c.handlers[c.index](c)
|
c.handlers[c.index](c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,8 +115,8 @@ func (c *Context) IsAborted() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abort prevents pending handlers from being called. Note that this will not stop the current handler.
|
// Abort prevents pending handlers from being called. Note that this will not stop the current handler.
|
||||||
// Let's say you have an authorization middleware that validates that the current request is authorized. If the
|
// Let's say you have an authorization middleware that validates that the current request is authorized.
|
||||||
// authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers
|
// If the authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers
|
||||||
// for this request are not called.
|
// for this request are not called.
|
||||||
func (c *Context) Abort() {
|
func (c *Context) Abort() {
|
||||||
c.index = abortIndex
|
c.index = abortIndex
|
||||||
@ -126,15 +130,16 @@ func (c *Context) AbortWithStatus(code int) {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortWithStatusJSON calls `Abort()` and then `JSON` internally. This method stops the chain, writes the status code and return a JSON body
|
// AbortWithStatusJSON calls `Abort()` and then `JSON` internally.
|
||||||
|
// This method stops the chain, writes the status code and return a JSON body.
|
||||||
// It also sets the Content-Type as "application/json".
|
// It also sets the Content-Type as "application/json".
|
||||||
func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{}) {
|
func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{}) {
|
||||||
c.Abort()
|
c.Abort()
|
||||||
c.JSON(code, jsonObj)
|
c.JSON(code, jsonObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortWithError calls `AbortWithStatus()` and `Error()` internally. This method stops the chain, writes the status code and
|
// AbortWithError calls `AbortWithStatus()` and `Error()` internally.
|
||||||
// pushes the specified error to `c.Errors`.
|
// This method stops the chain, writes the status code and pushes the specified error to `c.Errors`.
|
||||||
// See Context.Error() for more details.
|
// See Context.Error() for more details.
|
||||||
func (c *Context) AbortWithError(code int, err error) *Error {
|
func (c *Context) AbortWithError(code int, err error) *Error {
|
||||||
c.AbortWithStatus(code)
|
c.AbortWithStatus(code)
|
||||||
@ -145,21 +150,24 @@ func (c *Context) AbortWithError(code int, err error) *Error {
|
|||||||
/********* ERROR MANAGEMENT *********/
|
/********* ERROR MANAGEMENT *********/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
|
||||||
// Attaches an error to the current context. The error is pushed to a list of errors.
|
// Error attaches an error to the current context. The error is pushed to a list of errors.
|
||||||
// It's a good idea to call Error for each error that occurred during the resolution of a request.
|
// It's a good idea to call Error for each error that occurred during the resolution of a request.
|
||||||
// A middleware can be used to collect all the errors
|
// A middleware can be used to collect all the errors and push them to a database together,
|
||||||
// and push them to a database together, print a log, or append it in the HTTP response.
|
// print a log, or append it in the HTTP response.
|
||||||
|
// Error will panic if err is nil.
|
||||||
func (c *Context) Error(err error) *Error {
|
func (c *Context) Error(err error) *Error {
|
||||||
var parsedError *Error
|
if err == nil {
|
||||||
switch err.(type) {
|
panic("err is nil")
|
||||||
case *Error:
|
}
|
||||||
parsedError = err.(*Error)
|
|
||||||
default:
|
parsedError, ok := err.(*Error)
|
||||||
|
if !ok {
|
||||||
parsedError = &Error{
|
parsedError = &Error{
|
||||||
Err: err,
|
Err: err,
|
||||||
Type: ErrorTypePrivate,
|
Type: ErrorTypePrivate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Errors = append(c.Errors, parsedError)
|
c.Errors = append(c.Errors, parsedError)
|
||||||
return parsedError
|
return parsedError
|
||||||
}
|
}
|
||||||
@ -286,10 +294,10 @@ func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
|
|||||||
|
|
||||||
// Param returns the value of the URL param.
|
// Param returns the value of the URL param.
|
||||||
// It is a shortcut for c.Params.ByName(key)
|
// It is a shortcut for c.Params.ByName(key)
|
||||||
// router.GET("/user/:id", func(c *gin.Context) {
|
// router.GET("/user/:id", func(c *gin.Context) {
|
||||||
// // a GET request to /user/john
|
// // a GET request to /user/john
|
||||||
// id := c.Param("id") // id == "john"
|
// id := c.Param("id") // id == "john"
|
||||||
// })
|
// })
|
||||||
func (c *Context) Param(key string) string {
|
func (c *Context) Param(key string) string {
|
||||||
return c.Params.ByName(key)
|
return c.Params.ByName(key)
|
||||||
}
|
}
|
||||||
@ -297,11 +305,11 @@ func (c *Context) Param(key string) string {
|
|||||||
// Query returns the keyed url query value if it exists,
|
// Query returns the keyed url query value if it exists,
|
||||||
// otherwise it returns an empty string `("")`.
|
// otherwise it returns an empty string `("")`.
|
||||||
// It is shortcut for `c.Request.URL.Query().Get(key)`
|
// It is shortcut for `c.Request.URL.Query().Get(key)`
|
||||||
// GET /path?id=1234&name=Manu&value=
|
// GET /path?id=1234&name=Manu&value=
|
||||||
// c.Query("id") == "1234"
|
// c.Query("id") == "1234"
|
||||||
// c.Query("name") == "Manu"
|
// c.Query("name") == "Manu"
|
||||||
// c.Query("value") == ""
|
// c.Query("value") == ""
|
||||||
// c.Query("wtf") == ""
|
// c.Query("wtf") == ""
|
||||||
func (c *Context) Query(key string) string {
|
func (c *Context) Query(key string) string {
|
||||||
value, _ := c.GetQuery(key)
|
value, _ := c.GetQuery(key)
|
||||||
return value
|
return value
|
||||||
@ -310,10 +318,10 @@ func (c *Context) Query(key string) string {
|
|||||||
// DefaultQuery returns the keyed url query value if it exists,
|
// DefaultQuery returns the keyed url query value if it exists,
|
||||||
// otherwise it returns the specified defaultValue string.
|
// otherwise it returns the specified defaultValue string.
|
||||||
// See: Query() and GetQuery() for further information.
|
// See: Query() and GetQuery() for further information.
|
||||||
// GET /?name=Manu&lastname=
|
// GET /?name=Manu&lastname=
|
||||||
// c.DefaultQuery("name", "unknown") == "Manu"
|
// c.DefaultQuery("name", "unknown") == "Manu"
|
||||||
// c.DefaultQuery("id", "none") == "none"
|
// c.DefaultQuery("id", "none") == "none"
|
||||||
// c.DefaultQuery("lastname", "none") == ""
|
// c.DefaultQuery("lastname", "none") == ""
|
||||||
func (c *Context) DefaultQuery(key, defaultValue string) string {
|
func (c *Context) DefaultQuery(key, defaultValue string) string {
|
||||||
if value, ok := c.GetQuery(key); ok {
|
if value, ok := c.GetQuery(key); ok {
|
||||||
return value
|
return value
|
||||||
@ -325,10 +333,10 @@ func (c *Context) DefaultQuery(key, defaultValue string) string {
|
|||||||
// if it exists `(value, true)` (even when the value is an empty string),
|
// if it exists `(value, true)` (even when the value is an empty string),
|
||||||
// otherwise it returns `("", false)`.
|
// otherwise it returns `("", false)`.
|
||||||
// It is shortcut for `c.Request.URL.Query().Get(key)`
|
// It is shortcut for `c.Request.URL.Query().Get(key)`
|
||||||
// GET /?name=Manu&lastname=
|
// GET /?name=Manu&lastname=
|
||||||
// ("Manu", true) == c.GetQuery("name")
|
// ("Manu", true) == c.GetQuery("name")
|
||||||
// ("", false) == c.GetQuery("id")
|
// ("", false) == c.GetQuery("id")
|
||||||
// ("", true) == c.GetQuery("lastname")
|
// ("", true) == c.GetQuery("lastname")
|
||||||
func (c *Context) GetQuery(key string) (string, bool) {
|
func (c *Context) GetQuery(key string) (string, bool) {
|
||||||
if values, ok := c.GetQueryArray(key); ok {
|
if values, ok := c.GetQueryArray(key); ok {
|
||||||
return values[0], ok
|
return values[0], ok
|
||||||
@ -346,13 +354,24 @@ func (c *Context) QueryArray(key string) []string {
|
|||||||
// GetQueryArray returns a slice of strings for a given query key, plus
|
// GetQueryArray returns a slice of strings for a given query key, plus
|
||||||
// a boolean value whether at least one value exists for the given key.
|
// a boolean value whether at least one value exists for the given key.
|
||||||
func (c *Context) GetQueryArray(key string) ([]string, bool) {
|
func (c *Context) GetQueryArray(key string) ([]string, bool) {
|
||||||
req := c.Request
|
if values, ok := c.Request.URL.Query()[key]; ok && len(values) > 0 {
|
||||||
if values, ok := req.URL.Query()[key]; ok && len(values) > 0 {
|
|
||||||
return values, true
|
return values, true
|
||||||
}
|
}
|
||||||
return []string{}, false
|
return []string{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryMap returns a map for a given query key.
|
||||||
|
func (c *Context) QueryMap(key string) map[string]string {
|
||||||
|
dicts, _ := c.GetQueryMap(key)
|
||||||
|
return dicts
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetQueryMap returns a map for a given query key, plus a boolean value
|
||||||
|
// whether at least one value exists for the given key.
|
||||||
|
func (c *Context) GetQueryMap(key string) (map[string]string, bool) {
|
||||||
|
return c.get(c.Request.URL.Query(), key)
|
||||||
|
}
|
||||||
|
|
||||||
// PostForm returns the specified key from a POST urlencoded form or multipart form
|
// PostForm returns the specified key from a POST urlencoded form or multipart form
|
||||||
// when it exists, otherwise it returns an empty string `("")`.
|
// when it exists, otherwise it returns an empty string `("")`.
|
||||||
func (c *Context) PostForm(key string) string {
|
func (c *Context) PostForm(key string) string {
|
||||||
@ -374,9 +393,9 @@ func (c *Context) DefaultPostForm(key, defaultValue string) string {
|
|||||||
// form or multipart form when it exists `(value, true)` (even when the value is an empty string),
|
// form or multipart form when it exists `(value, true)` (even when the value is an empty string),
|
||||||
// otherwise it returns ("", false).
|
// otherwise it returns ("", false).
|
||||||
// For example, during a PATCH request to update the user's email:
|
// For example, during a PATCH request to update the user's email:
|
||||||
// email=mail@example.com --> ("mail@example.com", true) := GetPostForm("email") // set email to "mail@example.com"
|
// email=mail@example.com --> ("mail@example.com", true) := GetPostForm("email") // set email to "mail@example.com"
|
||||||
// email= --> ("", true) := GetPostForm("email") // set email to ""
|
// email= --> ("", true) := GetPostForm("email") // set email to ""
|
||||||
// --> ("", false) := GetPostForm("email") // do nothing with email
|
// --> ("", false) := GetPostForm("email") // do nothing with email
|
||||||
func (c *Context) GetPostForm(key string) (string, bool) {
|
func (c *Context) GetPostForm(key string) (string, bool) {
|
||||||
if values, ok := c.GetPostFormArray(key); ok {
|
if values, ok := c.GetPostFormArray(key); ok {
|
||||||
return values[0], ok
|
return values[0], ok
|
||||||
@ -396,7 +415,7 @@ func (c *Context) PostFormArray(key string) []string {
|
|||||||
func (c *Context) GetPostFormArray(key string) ([]string, bool) {
|
func (c *Context) GetPostFormArray(key string) ([]string, bool) {
|
||||||
req := c.Request
|
req := c.Request
|
||||||
req.ParseForm()
|
req.ParseForm()
|
||||||
req.ParseMultipartForm(defaultMemory)
|
req.ParseMultipartForm(c.engine.MaxMultipartMemory)
|
||||||
if values := req.PostForm[key]; len(values) > 0 {
|
if values := req.PostForm[key]; len(values) > 0 {
|
||||||
return values, true
|
return values, true
|
||||||
}
|
}
|
||||||
@ -408,6 +427,42 @@ func (c *Context) GetPostFormArray(key string) ([]string, bool) {
|
|||||||
return []string{}, false
|
return []string{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostFormMap returns a map for a given form key.
|
||||||
|
func (c *Context) PostFormMap(key string) map[string]string {
|
||||||
|
dicts, _ := c.GetPostFormMap(key)
|
||||||
|
return dicts
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPostFormMap returns a map for a given form key, plus a boolean value
|
||||||
|
// whether at least one value exists for the given key.
|
||||||
|
func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {
|
||||||
|
req := c.Request
|
||||||
|
req.ParseForm()
|
||||||
|
req.ParseMultipartForm(c.engine.MaxMultipartMemory)
|
||||||
|
dicts, exist := c.get(req.PostForm, key)
|
||||||
|
|
||||||
|
if !exist && req.MultipartForm != nil && req.MultipartForm.File != nil {
|
||||||
|
dicts, exist = c.get(req.MultipartForm.Value, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
return dicts, exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// get is an internal method and returns a map which satisfy conditions.
|
||||||
|
func (c *Context) get(m map[string][]string, key string) (map[string]string, bool) {
|
||||||
|
dicts := make(map[string]string)
|
||||||
|
exist := false
|
||||||
|
for k, v := range m {
|
||||||
|
if i := strings.IndexByte(k, '['); i >= 1 && k[0:i] == key {
|
||||||
|
if j := strings.IndexByte(k[i+1:], ']'); j >= 1 {
|
||||||
|
exist = true
|
||||||
|
dicts[k[i+1:][:j]] = v[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dicts, exist
|
||||||
|
}
|
||||||
|
|
||||||
// FormFile returns the first file for the provided form key.
|
// FormFile returns the first file for the provided form key.
|
||||||
func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
|
func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
|
||||||
_, fh, err := c.Request.FormFile(name)
|
_, fh, err := c.Request.FormFile(name)
|
||||||
@ -416,67 +471,132 @@ func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
|
|||||||
|
|
||||||
// MultipartForm is the parsed multipart form, including file uploads.
|
// MultipartForm is the parsed multipart form, including file uploads.
|
||||||
func (c *Context) MultipartForm() (*multipart.Form, error) {
|
func (c *Context) MultipartForm() (*multipart.Form, error) {
|
||||||
err := c.Request.ParseMultipartForm(defaultMemory)
|
err := c.Request.ParseMultipartForm(c.engine.MaxMultipartMemory)
|
||||||
return c.Request.MultipartForm, err
|
return c.Request.MultipartForm, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SaveUploadedFile uploads the form file to specific dst.
|
||||||
|
func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error {
|
||||||
|
src, err := file.Open()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer src.Close()
|
||||||
|
|
||||||
|
out, err := os.Create(dst)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
io.Copy(out, src)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Bind checks the Content-Type to select a binding engine automatically,
|
// Bind checks the Content-Type to select a binding engine automatically,
|
||||||
// Depending the "Content-Type" header different bindings are used:
|
// Depending the "Content-Type" header different bindings are used:
|
||||||
// "application/json" --> JSON binding
|
// "application/json" --> JSON binding
|
||||||
// "application/xml" --> XML binding
|
// "application/xml" --> XML binding
|
||||||
// otherwise --> returns an error
|
// otherwise --> returns an error.
|
||||||
// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
|
// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
|
||||||
// It decodes the json payload into the struct specified as a pointer.
|
// It decodes the json payload into the struct specified as a pointer.
|
||||||
// Like ParseBody() but this method also writes a 400 error if the json is not valid.
|
// It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid.
|
||||||
func (c *Context) Bind(obj interface{}) error {
|
func (c *Context) Bind(obj interface{}) error {
|
||||||
b := binding.Default(c.Request.Method, c.ContentType())
|
b := binding.Default(c.Request.Method, c.ContentType())
|
||||||
return c.MustBindWith(obj, b)
|
return c.MustBindWith(obj, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON)
|
// BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON).
|
||||||
func (c *Context) BindJSON(obj interface{}) error {
|
func (c *Context) BindJSON(obj interface{}) error {
|
||||||
return c.MustBindWith(obj, binding.JSON)
|
return c.MustBindWith(obj, binding.JSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustBindWith binds the passed struct pointer using the specified binding
|
// BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).
|
||||||
// engine. It will abort the request with HTTP 400 if any error ocurrs.
|
func (c *Context) BindQuery(obj interface{}) error {
|
||||||
|
return c.MustBindWith(obj, binding.Query)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustBindWith binds the passed struct pointer using the specified binding engine.
|
||||||
|
// It will abort the request with HTTP 400 if any error ocurrs.
|
||||||
// See the binding package.
|
// See the binding package.
|
||||||
func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) {
|
func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) {
|
||||||
if err = c.ShouldBindWith(obj, b); err != nil {
|
if err = c.ShouldBindWith(obj, b); err != nil {
|
||||||
c.AbortWithError(400, err).SetType(ErrorTypeBind)
|
c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShouldBindWith binds the passed struct pointer using the specified binding
|
// ShouldBind checks the Content-Type to select a binding engine automatically,
|
||||||
// engine.
|
// Depending the "Content-Type" header different bindings are used:
|
||||||
|
// "application/json" --> JSON binding
|
||||||
|
// "application/xml" --> XML binding
|
||||||
|
// otherwise --> returns an error
|
||||||
|
// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
|
||||||
|
// It decodes the json payload into the struct specified as a pointer.
|
||||||
|
// Like c.Bind() but this method does not set the response status code to 400 and abort if the json is not valid.
|
||||||
|
func (c *Context) ShouldBind(obj interface{}) error {
|
||||||
|
b := binding.Default(c.Request.Method, c.ContentType())
|
||||||
|
return c.ShouldBindWith(obj, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).
|
||||||
|
func (c *Context) ShouldBindJSON(obj interface{}) error {
|
||||||
|
return c.ShouldBindWith(obj, binding.JSON)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).
|
||||||
|
func (c *Context) ShouldBindQuery(obj interface{}) error {
|
||||||
|
return c.ShouldBindWith(obj, binding.Query)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ShouldBindWith binds the passed struct pointer using the specified binding engine.
|
||||||
// See the binding package.
|
// See the binding package.
|
||||||
func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error {
|
func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error {
|
||||||
return b.Bind(c.Request, obj)
|
return b.Bind(c.Request, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShouldBindBodyWith is similar with ShouldBindWith, but it stores the request
|
||||||
|
// body into the context, and reuse when it is called again.
|
||||||
|
//
|
||||||
|
// NOTE: This method reads the body before binding. So you should use
|
||||||
|
// ShouldBindWith for better performance if you need to call only once.
|
||||||
|
func (c *Context) ShouldBindBodyWith(
|
||||||
|
obj interface{}, bb binding.BindingBody,
|
||||||
|
) (err error) {
|
||||||
|
var body []byte
|
||||||
|
if cb, ok := c.Get(BodyBytesKey); ok {
|
||||||
|
if cbb, ok := cb.([]byte); ok {
|
||||||
|
body = cbb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if body == nil {
|
||||||
|
body, err = ioutil.ReadAll(c.Request.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.Set(BodyBytesKey, body)
|
||||||
|
}
|
||||||
|
return bb.BindBody(body, obj)
|
||||||
|
}
|
||||||
|
|
||||||
// ClientIP implements a best effort algorithm to return the real client IP, it parses
|
// ClientIP implements a best effort algorithm to return the real client IP, it parses
|
||||||
// X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy.
|
// X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy.
|
||||||
// Use X-Forwarded-For before X-Real-Ip as nginx uses X-Real-Ip with the proxy's IP.
|
// Use X-Forwarded-For before X-Real-Ip as nginx uses X-Real-Ip with the proxy's IP.
|
||||||
func (c *Context) ClientIP() string {
|
func (c *Context) ClientIP() string {
|
||||||
if c.engine.ForwardedByClientIP {
|
if c.engine.ForwardedByClientIP {
|
||||||
clientIP := c.requestHeader("X-Forwarded-For")
|
clientIP := c.requestHeader("X-Forwarded-For")
|
||||||
if index := strings.IndexByte(clientIP, ','); index >= 0 {
|
clientIP = strings.TrimSpace(strings.Split(clientIP, ",")[0])
|
||||||
clientIP = clientIP[0:index]
|
if clientIP == "" {
|
||||||
|
clientIP = strings.TrimSpace(c.requestHeader("X-Real-Ip"))
|
||||||
}
|
}
|
||||||
clientIP = strings.TrimSpace(clientIP)
|
if clientIP != "" {
|
||||||
if len(clientIP) > 0 {
|
|
||||||
return clientIP
|
|
||||||
}
|
|
||||||
clientIP = strings.TrimSpace(c.requestHeader("X-Real-Ip"))
|
|
||||||
if len(clientIP) > 0 {
|
|
||||||
return clientIP
|
return clientIP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.engine.AppEngine {
|
if c.engine.AppEngine {
|
||||||
if addr := c.Request.Header.Get("X-Appengine-Remote-Addr"); addr != "" {
|
if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,63 +624,56 @@ func (c *Context) IsWebsocket() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) requestHeader(key string) string {
|
func (c *Context) requestHeader(key string) string {
|
||||||
if values, _ := c.Request.Header[key]; len(values) > 0 {
|
return c.Request.Header.Get(key)
|
||||||
return values[0]
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
/******** RESPONSE RENDERING ********/
|
/******** RESPONSE RENDERING ********/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
|
||||||
// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function
|
// bodyAllowedForStatus is a copy of http.bodyAllowedForStatus non-exported function.
|
||||||
func bodyAllowedForStatus(status int) bool {
|
func bodyAllowedForStatus(status int) bool {
|
||||||
switch {
|
switch {
|
||||||
case status >= 100 && status <= 199:
|
case status >= 100 && status <= 199:
|
||||||
return false
|
return false
|
||||||
case status == 204:
|
case status == http.StatusNoContent:
|
||||||
return false
|
return false
|
||||||
case status == 304:
|
case status == http.StatusNotModified:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Status sets the HTTP response code.
|
||||||
func (c *Context) Status(code int) {
|
func (c *Context) Status(code int) {
|
||||||
c.writermem.WriteHeader(code)
|
c.writermem.WriteHeader(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header is a intelligent shortcut for c.Writer.Header().Set(key, value)
|
// Header is a intelligent shortcut for c.Writer.Header().Set(key, value).
|
||||||
// It writes a header in the response.
|
// It writes a header in the response.
|
||||||
// If value == "", this method removes the header `c.Writer.Header().Del(key)`
|
// If value == "", this method removes the header `c.Writer.Header().Del(key)`
|
||||||
func (c *Context) Header(key, value string) {
|
func (c *Context) Header(key, value string) {
|
||||||
if len(value) == 0 {
|
if value == "" {
|
||||||
c.Writer.Header().Del(key)
|
c.Writer.Header().Del(key)
|
||||||
} else {
|
} else {
|
||||||
c.Writer.Header().Set(key, value)
|
c.Writer.Header().Set(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHeader returns value from request headers
|
// GetHeader returns value from request headers.
|
||||||
func (c *Context) GetHeader(key string) string {
|
func (c *Context) GetHeader(key string) string {
|
||||||
return c.requestHeader(key)
|
return c.requestHeader(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawData return stream data
|
// GetRawData return stream data.
|
||||||
func (c *Context) GetRawData() ([]byte, error) {
|
func (c *Context) GetRawData() ([]byte, error) {
|
||||||
return ioutil.ReadAll(c.Request.Body)
|
return ioutil.ReadAll(c.Request.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) SetCookie(
|
// SetCookie adds a Set-Cookie header to the ResponseWriter's headers.
|
||||||
name string,
|
// The provided cookie must have a valid Name. Invalid cookies may be
|
||||||
value string,
|
// silently dropped.
|
||||||
maxAge int,
|
func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) {
|
||||||
path string,
|
|
||||||
domain string,
|
|
||||||
secure bool,
|
|
||||||
httpOnly bool,
|
|
||||||
) {
|
|
||||||
if path == "" {
|
if path == "" {
|
||||||
path = "/"
|
path = "/"
|
||||||
}
|
}
|
||||||
@ -575,6 +688,10 @@ func (c *Context) SetCookie(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cookie returns the named cookie provided in the request or
|
||||||
|
// ErrNoCookie if not found. And return the named cookie is unescaped.
|
||||||
|
// If multiple cookies match the given name, only one cookie will
|
||||||
|
// be returned.
|
||||||
func (c *Context) Cookie(name string) (string, error) {
|
func (c *Context) Cookie(name string) (string, error) {
|
||||||
cookie, err := c.Request.Cookie(name)
|
cookie, err := c.Request.Cookie(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -614,12 +731,37 @@ func (c *Context) IndentedJSON(code int, obj interface{}) {
|
|||||||
c.Render(code, render.IndentedJSON{Data: obj})
|
c.Render(code, render.IndentedJSON{Data: obj})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SecureJSON serializes the given struct as Secure JSON into the response body.
|
||||||
|
// Default prepends "while(1)," to response body if the given struct is array values.
|
||||||
|
// It also sets the Content-Type as "application/json".
|
||||||
|
func (c *Context) SecureJSON(code int, obj interface{}) {
|
||||||
|
c.Render(code, render.SecureJSON{Prefix: c.engine.secureJsonPrefix, Data: obj})
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONP serializes the given struct as JSON into the response body.
|
||||||
|
// It add padding to response body to request data from a server residing in a different domain than the client.
|
||||||
|
// It also sets the Content-Type as "application/javascript".
|
||||||
|
func (c *Context) JSONP(code int, obj interface{}) {
|
||||||
|
callback := c.DefaultQuery("callback", "")
|
||||||
|
if callback == "" {
|
||||||
|
c.Render(code, render.JSON{Data: obj})
|
||||||
|
} else {
|
||||||
|
c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// JSON serializes the given struct as JSON into the response body.
|
// JSON serializes the given struct as JSON into the response body.
|
||||||
// It also sets the Content-Type as "application/json".
|
// It also sets the Content-Type as "application/json".
|
||||||
func (c *Context) JSON(code int, obj interface{}) {
|
func (c *Context) JSON(code int, obj interface{}) {
|
||||||
c.Render(code, render.JSON{Data: obj})
|
c.Render(code, render.JSON{Data: obj})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string.
|
||||||
|
// It also sets the Content-Type as "application/json".
|
||||||
|
func (c *Context) AsciiJSON(code int, obj interface{}) {
|
||||||
|
c.Render(code, render.AsciiJSON{Data: obj})
|
||||||
|
}
|
||||||
|
|
||||||
// XML serializes the given struct as XML into the response body.
|
// XML serializes the given struct as XML into the response body.
|
||||||
// It also sets the Content-Type as "application/xml".
|
// It also sets the Content-Type as "application/xml".
|
||||||
func (c *Context) XML(code int, obj interface{}) {
|
func (c *Context) XML(code int, obj interface{}) {
|
||||||
@ -653,6 +795,16 @@ func (c *Context) Data(code int, contentType string, data []byte) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DataFromReader writes the specified reader into the body stream and updates the HTTP code.
|
||||||
|
func (c *Context) DataFromReader(code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string) {
|
||||||
|
c.Render(code, render.Reader{
|
||||||
|
Headers: extraHeaders,
|
||||||
|
ContentType: contentType,
|
||||||
|
ContentLength: contentLength,
|
||||||
|
Reader: reader,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// File writes the specified file into the body stream in a efficient way.
|
// File writes the specified file into the body stream in a efficient way.
|
||||||
func (c *Context) File(filepath string) {
|
func (c *Context) File(filepath string) {
|
||||||
http.ServeFile(c.Writer, c.Request, filepath)
|
http.ServeFile(c.Writer, c.Request, filepath)
|
||||||
@ -742,18 +894,33 @@ func (c *Context) SetAccepted(formats ...string) {
|
|||||||
/***** GOLANG.ORG/X/NET/CONTEXT *****/
|
/***** GOLANG.ORG/X/NET/CONTEXT *****/
|
||||||
/************************************/
|
/************************************/
|
||||||
|
|
||||||
|
// Deadline returns the time when work done on behalf of this context
|
||||||
|
// should be canceled. Deadline returns ok==false when no deadline is
|
||||||
|
// set. Successive calls to Deadline return the same results.
|
||||||
func (c *Context) Deadline() (deadline time.Time, ok bool) {
|
func (c *Context) Deadline() (deadline time.Time, ok bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Done returns a channel that's closed when work done on behalf of this
|
||||||
|
// context should be canceled. Done may return nil if this context can
|
||||||
|
// never be canceled. Successive calls to Done return the same value.
|
||||||
func (c *Context) Done() <-chan struct{} {
|
func (c *Context) Done() <-chan struct{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Err returns a non-nil error value after Done is closed,
|
||||||
|
// successive calls to Err return the same error.
|
||||||
|
// If Done is not yet closed, Err returns nil.
|
||||||
|
// If Done is closed, Err returns a non-nil error explaining why:
|
||||||
|
// Canceled if the context was canceled
|
||||||
|
// or DeadlineExceeded if the context's deadline passed.
|
||||||
func (c *Context) Err() error {
|
func (c *Context) Err() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Value returns the value associated with this context for key, or nil
|
||||||
|
// if no value is associated with key. Successive calls to Value with
|
||||||
|
// the same key returns the same result.
|
||||||
func (c *Context) Value(key interface{}) interface{} {
|
func (c *Context) Value(key interface{}) interface{} {
|
||||||
if key == 0 {
|
if key == 0 {
|
||||||
return c.Request
|
return c.Request
|
||||||
|
802
vendor/github.com/gin-gonic/gin/context_test.go
generated
vendored
802
vendor/github.com/gin-gonic/gin/context_test.go
generated
vendored
File diff suppressed because it is too large
Load Diff
13
vendor/github.com/gin-gonic/gin/coverage.sh
generated
vendored
Normal file
13
vendor/github.com/gin-gonic/gin/coverage.sh
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "mode: count" > coverage.out
|
||||||
|
|
||||||
|
for d in $(go list ./... | grep -E 'gin$|binding$|render$' | grep -v 'examples'); do
|
||||||
|
go test -v -covermode=count -coverprofile=profile.out $d
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
cat profile.out | grep -v "mode:" >> coverage.out
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
done
|
11
vendor/github.com/gin-gonic/gin/debug.go
generated
vendored
11
vendor/github.com/gin-gonic/gin/debug.go
generated
vendored
@ -15,7 +15,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsDebugging returns true if the framework is running in debug mode.
|
// IsDebugging returns true if the framework is running in debug mode.
|
||||||
// Use SetMode(gin.Release) to switch to disable the debug mode.
|
// Use SetMode(gin.ReleaseMode) to disable debug mode.
|
||||||
func IsDebugging() bool {
|
func IsDebugging() bool {
|
||||||
return ginMode == debugCode
|
return ginMode == debugCode
|
||||||
}
|
}
|
||||||
@ -46,6 +46,15 @@ func debugPrint(format string, values ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func debugPrintWARNINGDefault() {
|
||||||
|
debugPrint(`[WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.
|
||||||
|
|
||||||
|
`)
|
||||||
|
debugPrint(`[WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
|
||||||
|
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
func debugPrintWARNINGNew() {
|
func debugPrintWARNINGNew() {
|
||||||
debugPrint(`[WARNING] Running in "debug" mode. Switch to "release" mode in production.
|
debugPrint(`[WARNING] Running in "debug" mode. Switch to "release" mode in production.
|
||||||
- using env: export GIN_MODE=release
|
- using env: export GIN_MODE=release
|
||||||
|
28
vendor/github.com/gin-gonic/gin/debug_test.go
generated
vendored
28
vendor/github.com/gin-gonic/gin/debug_test.go
generated
vendored
@ -42,7 +42,7 @@ func TestDebugPrint(t *testing.T) {
|
|||||||
|
|
||||||
SetMode(DebugMode)
|
SetMode(DebugMode)
|
||||||
debugPrint("these are %d %s\n", 2, "error messages")
|
debugPrint("these are %d %s\n", 2, "error messages")
|
||||||
assert.Equal(t, w.String(), "[GIN-debug] these are 2 error messages\n")
|
assert.Equal(t, "[GIN-debug] these are 2 error messages\n", w.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDebugPrintError(t *testing.T) {
|
func TestDebugPrintError(t *testing.T) {
|
||||||
@ -55,7 +55,7 @@ func TestDebugPrintError(t *testing.T) {
|
|||||||
assert.Empty(t, w.String())
|
assert.Empty(t, w.String())
|
||||||
|
|
||||||
debugPrintError(errors.New("this is an error"))
|
debugPrintError(errors.New("this is an error"))
|
||||||
assert.Equal(t, w.String(), "[GIN-debug] [ERROR] this is an error\n")
|
assert.Equal(t, "[GIN-debug] [ERROR] this is an error\n", w.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDebugPrintRoutes(t *testing.T) {
|
func TestDebugPrintRoutes(t *testing.T) {
|
||||||
@ -72,9 +72,9 @@ func TestDebugPrintLoadTemplate(t *testing.T) {
|
|||||||
setup(&w)
|
setup(&w)
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
templ := template.Must(template.New("").Delims("{[{", "}]}").ParseGlob("./fixtures/basic/hello.tmpl"))
|
templ := template.Must(template.New("").Delims("{[{", "}]}").ParseGlob("./testdata/template/hello.tmpl"))
|
||||||
debugPrintLoadTemplate(templ)
|
debugPrintLoadTemplate(templ)
|
||||||
assert.Equal(t, w.String(), "[GIN-debug] Loaded HTML Templates (2): \n\t- \n\t- hello.tmpl\n\n")
|
assert.Regexp(t, `^\[GIN-debug\] Loaded HTML Templates \(2\): \n(\t- \n|\t- hello\.tmpl\n){2}\n`, w.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDebugPrintWARNINGSetHTMLTemplate(t *testing.T) {
|
func TestDebugPrintWARNINGSetHTMLTemplate(t *testing.T) {
|
||||||
@ -83,7 +83,25 @@ func TestDebugPrintWARNINGSetHTMLTemplate(t *testing.T) {
|
|||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
||||||
debugPrintWARNINGSetHTMLTemplate()
|
debugPrintWARNINGSetHTMLTemplate()
|
||||||
assert.Equal(t, w.String(), "[GIN-debug] [WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called\nat initialization. ie. before any route is registered or the router is listening in a socket:\n\n\trouter := gin.Default()\n\trouter.SetHTMLTemplate(template) // << good place\n\n")
|
assert.Equal(t, "[GIN-debug] [WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called\nat initialization. ie. before any route is registered or the router is listening in a socket:\n\n\trouter := gin.Default()\n\trouter.SetHTMLTemplate(template) // << good place\n\n", w.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDebugPrintWARNINGDefault(t *testing.T) {
|
||||||
|
var w bytes.Buffer
|
||||||
|
setup(&w)
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
debugPrintWARNINGDefault()
|
||||||
|
assert.Equal(t, "[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.\n\n[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", w.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDebugPrintWARNINGNew(t *testing.T) {
|
||||||
|
var w bytes.Buffer
|
||||||
|
setup(&w)
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
|
debugPrintWARNINGNew()
|
||||||
|
assert.Equal(t, "[GIN-debug] [WARNING] Running in \"debug\" mode. Switch to \"release\" mode in production.\n - using env:\texport GIN_MODE=release\n - using code:\tgin.SetMode(gin.ReleaseMode)\n\n", w.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup(w io.Writer) {
|
func setup(w io.Writer) {
|
||||||
|
10
vendor/github.com/gin-gonic/gin/deprecated.go
generated
vendored
10
vendor/github.com/gin-gonic/gin/deprecated.go
generated
vendored
@ -5,21 +5,17 @@
|
|||||||
package gin
|
package gin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin/binding"
|
|
||||||
"log"
|
"log"
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Context) GetCookie(name string) (string, error) {
|
"github.com/gin-gonic/gin/binding"
|
||||||
log.Println("GetCookie() method is deprecated. Use Cookie() instead.")
|
)
|
||||||
return c.Cookie(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BindWith binds the passed struct pointer using the specified binding engine.
|
// BindWith binds the passed struct pointer using the specified binding engine.
|
||||||
// See the binding package.
|
// See the binding package.
|
||||||
func (c *Context) BindWith(obj interface{}, b binding.Binding) error {
|
func (c *Context) BindWith(obj interface{}, b binding.Binding) error {
|
||||||
log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to
|
log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to
|
||||||
be deprecated, please check issue #662 and either use MustBindWith() if you
|
be deprecated, please check issue #662 and either use MustBindWith() if you
|
||||||
want HTTP 400 to be automatically returned if any error occur, of use
|
want HTTP 400 to be automatically returned if any error occur, or use
|
||||||
ShouldBindWith() if you need to manage the error.`)
|
ShouldBindWith() if you need to manage the error.`)
|
||||||
return c.MustBindWith(obj, b)
|
return c.MustBindWith(obj, b)
|
||||||
}
|
}
|
||||||
|
31
vendor/github.com/gin-gonic/gin/deprecated_test.go
generated
vendored
Normal file
31
vendor/github.com/gin-gonic/gin/deprecated_test.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package gin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBindWith(t *testing.T) {
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := CreateTestContext(w)
|
||||||
|
|
||||||
|
c.Request, _ = http.NewRequest("POST", "/?foo=bar&bar=foo", bytes.NewBufferString("foo=unused"))
|
||||||
|
|
||||||
|
var obj struct {
|
||||||
|
Foo string `form:"foo"`
|
||||||
|
Bar string `form:"bar"`
|
||||||
|
}
|
||||||
|
assert.NoError(t, c.BindWith(&obj, binding.Form))
|
||||||
|
assert.Equal(t, "foo", obj.Bar)
|
||||||
|
assert.Equal(t, "bar", obj.Foo)
|
||||||
|
assert.Equal(t, 0, w.Body.Len())
|
||||||
|
}
|
6
vendor/github.com/gin-gonic/gin/doc.go
generated
vendored
Normal file
6
vendor/github.com/gin-gonic/gin/doc.go
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
Package gin implements a HTTP web framework called gin.
|
||||||
|
|
||||||
|
See https://gin-gonic.github.io/gin/ for more information about gin.
|
||||||
|
*/
|
||||||
|
package gin // import "github.com/gin-gonic/gin"
|
36
vendor/github.com/gin-gonic/gin/errors.go
generated
vendored
36
vendor/github.com/gin-gonic/gin/errors.go
generated
vendored
@ -6,9 +6,10 @@ package gin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorType uint64
|
type ErrorType uint64
|
||||||
@ -23,15 +24,13 @@ const (
|
|||||||
ErrorTypeNu = 2
|
ErrorTypeNu = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type Error struct {
|
||||||
Error struct {
|
Err error
|
||||||
Err error
|
Type ErrorType
|
||||||
Type ErrorType
|
Meta interface{}
|
||||||
Meta interface{}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
errorMsgs []*Error
|
type errorMsgs []*Error
|
||||||
)
|
|
||||||
|
|
||||||
var _ error = &Error{}
|
var _ error = &Error{}
|
||||||
|
|
||||||
@ -66,12 +65,12 @@ func (msg *Error) JSON() interface{} {
|
|||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaller interface
|
// MarshalJSON implements the json.Marshaller interface.
|
||||||
func (msg *Error) MarshalJSON() ([]byte, error) {
|
func (msg *Error) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(msg.JSON())
|
return json.Marshal(msg.JSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements the error interface
|
// Error implements the error interface
|
||||||
func (msg Error) Error() string {
|
func (msg Error) Error() string {
|
||||||
return msg.Err.Error()
|
return msg.Err.Error()
|
||||||
}
|
}
|
||||||
@ -80,8 +79,8 @@ func (msg *Error) IsType(flags ErrorType) bool {
|
|||||||
return (msg.Type & flags) > 0
|
return (msg.Type & flags) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a readonly copy filtered the byte.
|
// ByType returns a readonly copy filtered the byte.
|
||||||
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic
|
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic.
|
||||||
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
||||||
if len(a) == 0 {
|
if len(a) == 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -98,17 +97,16 @@ func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the last error in the slice. It returns nil if the array is empty.
|
// Last returns the last error in the slice. It returns nil if the array is empty.
|
||||||
// Shortcut for errors[len(errors)-1]
|
// Shortcut for errors[len(errors)-1].
|
||||||
func (a errorMsgs) Last() *Error {
|
func (a errorMsgs) Last() *Error {
|
||||||
length := len(a)
|
if length := len(a); length > 0 {
|
||||||
if length > 0 {
|
|
||||||
return a[length-1]
|
return a[length-1]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array will all the error messages.
|
// Errors returns an array will all the error messages.
|
||||||
// Example:
|
// Example:
|
||||||
// c.Error(errors.New("first"))
|
// c.Error(errors.New("first"))
|
||||||
// c.Error(errors.New("second"))
|
// c.Error(errors.New("second"))
|
||||||
@ -150,7 +148,7 @@ func (a errorMsgs) String() string {
|
|||||||
}
|
}
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
for i, msg := range a {
|
for i, msg := range a {
|
||||||
fmt.Fprintf(&buffer, "Error #%02d: %s\n", (i + 1), msg.Err)
|
fmt.Fprintf(&buffer, "Error #%02d: %s\n", i+1, msg.Err)
|
||||||
if msg.Meta != nil {
|
if msg.Meta != nil {
|
||||||
fmt.Fprintf(&buffer, " Meta: %v\n", msg.Meta)
|
fmt.Fprintf(&buffer, " Meta: %v\n", msg.Meta)
|
||||||
}
|
}
|
||||||
|
48
vendor/github.com/gin-gonic/gin/errors_test.go
generated
vendored
48
vendor/github.com/gin-gonic/gin/errors_test.go
generated
vendored
@ -5,10 +5,10 @@
|
|||||||
package gin
|
package gin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/json"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,48 +19,48 @@ func TestError(t *testing.T) {
|
|||||||
Type: ErrorTypePrivate,
|
Type: ErrorTypePrivate,
|
||||||
}
|
}
|
||||||
assert.Equal(t, err.Error(), baseError.Error())
|
assert.Equal(t, err.Error(), baseError.Error())
|
||||||
assert.Equal(t, err.JSON(), H{"error": baseError.Error()})
|
assert.Equal(t, H{"error": baseError.Error()}, err.JSON())
|
||||||
|
|
||||||
assert.Equal(t, err.SetType(ErrorTypePublic), err)
|
assert.Equal(t, err.SetType(ErrorTypePublic), err)
|
||||||
assert.Equal(t, err.Type, ErrorTypePublic)
|
assert.Equal(t, ErrorTypePublic, err.Type)
|
||||||
|
|
||||||
assert.Equal(t, err.SetMeta("some data"), err)
|
assert.Equal(t, err.SetMeta("some data"), err)
|
||||||
assert.Equal(t, err.Meta, "some data")
|
assert.Equal(t, "some data", err.Meta)
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": baseError.Error(),
|
"error": baseError.Error(),
|
||||||
"meta": "some data",
|
"meta": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
jsonBytes, _ := json.Marshal(err)
|
jsonBytes, _ := json.Marshal(err)
|
||||||
assert.Equal(t, string(jsonBytes), "{\"error\":\"test error\",\"meta\":\"some data\"}")
|
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
|
||||||
|
|
||||||
err.SetMeta(H{
|
err.SetMeta(H{
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
})
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": baseError.Error(),
|
"error": baseError.Error(),
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
err.SetMeta(H{
|
err.SetMeta(H{
|
||||||
"error": "custom error",
|
"error": "custom error",
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
})
|
||||||
assert.Equal(t, err.JSON(), H{
|
assert.Equal(t, H{
|
||||||
"error": "custom error",
|
"error": "custom error",
|
||||||
"status": "200",
|
"status": "200",
|
||||||
"data": "some data",
|
"data": "some data",
|
||||||
})
|
}, err.JSON())
|
||||||
|
|
||||||
type customError struct {
|
type customError struct {
|
||||||
status string
|
status string
|
||||||
data string
|
data string
|
||||||
}
|
}
|
||||||
err.SetMeta(customError{status: "200", data: "other data"})
|
err.SetMeta(customError{status: "200", data: "other data"})
|
||||||
assert.Equal(t, err.JSON(), customError{status: "200", data: "other data"})
|
assert.Equal(t, customError{status: "200", data: "other data"}, err.JSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestErrorSlice(t *testing.T) {
|
func TestErrorSlice(t *testing.T) {
|
||||||
@ -71,33 +71,33 @@ func TestErrorSlice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, errs, errs.ByType(ErrorTypeAny))
|
assert.Equal(t, errs, errs.ByType(ErrorTypeAny))
|
||||||
assert.Equal(t, errs.Last().Error(), "third")
|
assert.Equal(t, "third", errs.Last().Error())
|
||||||
assert.Equal(t, errs.Errors(), []string{"first", "second", "third"})
|
assert.Equal(t, []string{"first", "second", "third"}, errs.Errors())
|
||||||
assert.Equal(t, errs.ByType(ErrorTypePublic).Errors(), []string{"third"})
|
assert.Equal(t, []string{"third"}, errs.ByType(ErrorTypePublic).Errors())
|
||||||
assert.Equal(t, errs.ByType(ErrorTypePrivate).Errors(), []string{"first", "second"})
|
assert.Equal(t, []string{"first", "second"}, errs.ByType(ErrorTypePrivate).Errors())
|
||||||
assert.Equal(t, errs.ByType(ErrorTypePublic|ErrorTypePrivate).Errors(), []string{"first", "second", "third"})
|
assert.Equal(t, []string{"first", "second", "third"}, errs.ByType(ErrorTypePublic|ErrorTypePrivate).Errors())
|
||||||
assert.Empty(t, errs.ByType(ErrorTypeBind))
|
assert.Empty(t, errs.ByType(ErrorTypeBind))
|
||||||
assert.Empty(t, errs.ByType(ErrorTypeBind).String())
|
assert.Empty(t, errs.ByType(ErrorTypeBind).String())
|
||||||
|
|
||||||
assert.Equal(t, errs.String(), `Error #01: first
|
assert.Equal(t, `Error #01: first
|
||||||
Error #02: second
|
Error #02: second
|
||||||
Meta: some data
|
Meta: some data
|
||||||
Error #03: third
|
Error #03: third
|
||||||
Meta: map[status:400]
|
Meta: map[status:400]
|
||||||
`)
|
`, errs.String())
|
||||||
assert.Equal(t, errs.JSON(), []interface{}{
|
assert.Equal(t, []interface{}{
|
||||||
H{"error": "first"},
|
H{"error": "first"},
|
||||||
H{"error": "second", "meta": "some data"},
|
H{"error": "second", "meta": "some data"},
|
||||||
H{"error": "third", "status": "400"},
|
H{"error": "third", "status": "400"},
|
||||||
})
|
}, errs.JSON())
|
||||||
jsonBytes, _ := json.Marshal(errs)
|
jsonBytes, _ := json.Marshal(errs)
|
||||||
assert.Equal(t, string(jsonBytes), "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]")
|
assert.Equal(t, "[{\"error\":\"first\"},{\"error\":\"second\",\"meta\":\"some data\"},{\"error\":\"third\",\"status\":\"400\"}]", string(jsonBytes))
|
||||||
errs = errorMsgs{
|
errs = errorMsgs{
|
||||||
{Err: errors.New("first"), Type: ErrorTypePrivate},
|
{Err: errors.New("first"), Type: ErrorTypePrivate},
|
||||||
}
|
}
|
||||||
assert.Equal(t, errs.JSON(), H{"error": "first"})
|
assert.Equal(t, H{"error": "first"}, errs.JSON())
|
||||||
jsonBytes, _ = json.Marshal(errs)
|
jsonBytes, _ = json.Marshal(errs)
|
||||||
assert.Equal(t, string(jsonBytes), "{\"error\":\"first\"}")
|
assert.Equal(t, "{\"error\":\"first\"}", string(jsonBytes))
|
||||||
|
|
||||||
errs = errorMsgs{}
|
errs = errorMsgs{}
|
||||||
assert.Nil(t, errs.Last())
|
assert.Nil(t, errs.Last())
|
||||||
|
7
vendor/github.com/gin-gonic/gin/examples/app-engine/README.md
generated
vendored
7
vendor/github.com/gin-gonic/gin/examples/app-engine/README.md
generated
vendored
@ -1,7 +1,8 @@
|
|||||||
# Guide to run Gin under App Engine LOCAL Development Server
|
# Guide to run Gin under App Engine LOCAL Development Server
|
||||||
|
|
||||||
1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.)
|
1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.)
|
||||||
2. Download SDK for your platform from here: `https://developers.google.com/appengine/downloads?hl=es#Google_App_Engine_SDK_for_Go`
|
2. Download SDK for your platform from [here](https://cloud.google.com/appengine/docs/standard/go/download): `https://cloud.google.com/appengine/docs/standard/go/download`
|
||||||
3. Download Gin source code using: `$ go get github.com/gin-gonic/gin`
|
3. Download Gin source code using: `$ go get github.com/gin-gonic/gin`
|
||||||
4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/examples/`
|
4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/examples/app-engine/`
|
||||||
5. Run it: `$ goapp serve app-engine/`
|
5. Run it: `$ dev_appserver.py .` (notice that you have to run this script by Python2)
|
||||||
|
|
||||||
|
4
vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go
generated
vendored
4
vendor/github.com/gin-gonic/gin/examples/app-engine/hello.go
generated
vendored
@ -13,10 +13,10 @@ func init() {
|
|||||||
|
|
||||||
// Define your handlers
|
// Define your handlers
|
||||||
r.GET("/", func(c *gin.Context) {
|
r.GET("/", func(c *gin.Context) {
|
||||||
c.String(200, "Hello World!")
|
c.String(http.StatusOK, "Hello World!")
|
||||||
})
|
})
|
||||||
r.GET("/ping", func(c *gin.Context) {
|
r.GET("/ping", func(c *gin.Context) {
|
||||||
c.String(200, "pong")
|
c.String(http.StatusOK, "pong")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle all requests using net/http
|
// Handle all requests using net/http
|
||||||
|
33
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/README.md
generated
vendored
Normal file
33
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/README.md
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Building a single binary containing templates
|
||||||
|
|
||||||
|
This is a complete example to create a single binary with the
|
||||||
|
[gin-gonic/gin][gin] Web Server with HTML templates.
|
||||||
|
|
||||||
|
[gin]: https://github.com/gin-gonic/gin
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
### Prepare Packages
|
||||||
|
|
||||||
|
```
|
||||||
|
go get github.com/gin-gonic/gin
|
||||||
|
go get github.com/jessevdk/go-assets-builder
|
||||||
|
```
|
||||||
|
|
||||||
|
### Generate assets.go
|
||||||
|
|
||||||
|
```
|
||||||
|
go-assets-builder html -o assets.go
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build the server
|
||||||
|
|
||||||
|
```
|
||||||
|
go build -o assets-in-binary
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run
|
||||||
|
|
||||||
|
```
|
||||||
|
./assets-in-binary
|
||||||
|
```
|
34
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/assets.go
generated
vendored
Normal file
34
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/assets.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jessevdk/go-assets"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _Assetsbfa8d115ce0617d89507412d5393a462f8e9b003 = "<!doctype html>\n<body>\n <p>Can you see this? → {{.Bar}}</p>\n</body>\n"
|
||||||
|
var _Assets3737a75b5254ed1f6d588b40a3449721f9ea86c2 = "<!doctype html>\n<body>\n <p>Hello, {{.Foo}}</p>\n</body>\n"
|
||||||
|
|
||||||
|
// Assets returns go-assets FileSystem
|
||||||
|
var Assets = assets.NewFileSystem(map[string][]string{"/": {"html"}, "/html": {"bar.tmpl", "index.tmpl"}}, map[string]*assets.File{
|
||||||
|
"/": {
|
||||||
|
Path: "/",
|
||||||
|
FileMode: 0x800001ed,
|
||||||
|
Mtime: time.Unix(1524365738, 1524365738517125470),
|
||||||
|
Data: nil,
|
||||||
|
}, "/html": {
|
||||||
|
Path: "/html",
|
||||||
|
FileMode: 0x800001ed,
|
||||||
|
Mtime: time.Unix(1524365491, 1524365491289799093),
|
||||||
|
Data: nil,
|
||||||
|
}, "/html/bar.tmpl": {
|
||||||
|
Path: "/html/bar.tmpl",
|
||||||
|
FileMode: 0x1a4,
|
||||||
|
Mtime: time.Unix(1524365491, 1524365491289611557),
|
||||||
|
Data: []byte(_Assetsbfa8d115ce0617d89507412d5393a462f8e9b003),
|
||||||
|
}, "/html/index.tmpl": {
|
||||||
|
Path: "/html/index.tmpl",
|
||||||
|
FileMode: 0x1a4,
|
||||||
|
Mtime: time.Unix(1524365491, 1524365491289995821),
|
||||||
|
Data: []byte(_Assets3737a75b5254ed1f6d588b40a3449721f9ea86c2),
|
||||||
|
}}, "")
|
4
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/html/bar.tmpl
generated
vendored
Normal file
4
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/html/bar.tmpl
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<body>
|
||||||
|
<p>Can you see this? → {{.Bar}}</p>
|
||||||
|
</body>
|
4
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/html/index.tmpl
generated
vendored
Normal file
4
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/html/index.tmpl
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<body>
|
||||||
|
<p>Hello, {{.Foo}}</p>
|
||||||
|
</body>
|
48
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/main.go
generated
vendored
Normal file
48
vendor/github.com/gin-gonic/gin/examples/assets-in-binary/main.go
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := gin.New()
|
||||||
|
t, err := loadTemplate()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
r.SetHTMLTemplate(t)
|
||||||
|
r.GET("/", func(c *gin.Context) {
|
||||||
|
c.HTML(http.StatusOK, "/html/index.tmpl", gin.H{
|
||||||
|
"Foo": "World",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
r.GET("/bar", func(c *gin.Context) {
|
||||||
|
c.HTML(http.StatusOK, "/html/bar.tmpl", gin.H{
|
||||||
|
"Bar": "World",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
r.Run(":8080")
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadTemplate() (*template.Template, error) {
|
||||||
|
t := template.New("")
|
||||||
|
for name, file := range Assets.Files {
|
||||||
|
if file.IsDir() || !strings.HasSuffix(name, ".tmpl") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
h, err := ioutil.ReadAll(file)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
t, err = t.New(name).Parse(string(h))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
|
}
|
@ -22,5 +22,5 @@ func main() {
|
|||||||
Cache: autocert.DirCache("/var/www/.cache"),
|
Cache: autocert.DirCache("/var/www/.cache"),
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal(autotls.RunWithManager(r, m))
|
log.Fatal(autotls.RunWithManager(r, &m))
|
||||||
}
|
}
|
17
vendor/github.com/gin-gonic/gin/examples/basic/main.go
generated
vendored
17
vendor/github.com/gin-gonic/gin/examples/basic/main.go
generated
vendored
@ -1,19 +1,21 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var DB = make(map[string]string)
|
var DB = make(map[string]string)
|
||||||
|
|
||||||
func main() {
|
func setupRouter() *gin.Engine {
|
||||||
// Disable Console Color
|
// Disable Console Color
|
||||||
// gin.DisableConsoleColor()
|
// gin.DisableConsoleColor()
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
// Ping test
|
// Ping test
|
||||||
r.GET("/ping", func(c *gin.Context) {
|
r.GET("/ping", func(c *gin.Context) {
|
||||||
c.String(200, "pong")
|
c.String(http.StatusOK, "pong")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Get user value
|
// Get user value
|
||||||
@ -21,9 +23,9 @@ func main() {
|
|||||||
user := c.Params.ByName("name")
|
user := c.Params.ByName("name")
|
||||||
value, ok := DB[user]
|
value, ok := DB[user]
|
||||||
if ok {
|
if ok {
|
||||||
c.JSON(200, gin.H{"user": user, "value": value})
|
c.JSON(http.StatusOK, gin.H{"user": user, "value": value})
|
||||||
} else {
|
} else {
|
||||||
c.JSON(200, gin.H{"user": user, "status": "no value"})
|
c.JSON(http.StatusOK, gin.H{"user": user, "status": "no value"})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -49,10 +51,15 @@ func main() {
|
|||||||
|
|
||||||
if c.Bind(&json) == nil {
|
if c.Bind(&json) == nil {
|
||||||
DB[user] = json.Value
|
DB[user] = json.Value
|
||||||
c.JSON(200, gin.H{"status": "ok"})
|
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := setupRouter()
|
||||||
// Listen and Server in 0.0.0.0:8080
|
// Listen and Server in 0.0.0.0:8080
|
||||||
r.Run(":8080")
|
r.Run(":8080")
|
||||||
}
|
}
|
||||||
|
20
vendor/github.com/gin-gonic/gin/examples/basic/main_test.go
generated
vendored
Normal file
20
vendor/github.com/gin-gonic/gin/examples/basic/main_test.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPingRoute(t *testing.T) {
|
||||||
|
router := setupRouter()
|
||||||
|
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
req, _ := http.NewRequest("GET", "/ping", nil)
|
||||||
|
router.ServeHTTP(w, req)
|
||||||
|
|
||||||
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
|
assert.Equal(t, "pong", w.Body.String())
|
||||||
|
}
|
49
vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go
generated
vendored
Normal file
49
vendor/github.com/gin-gonic/gin/examples/custom-validation/server.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
"gopkg.in/go-playground/validator.v8"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Booking struct {
|
||||||
|
CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
|
||||||
|
CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func bookableDate(
|
||||||
|
v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
|
||||||
|
field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
|
||||||
|
) bool {
|
||||||
|
if date, ok := field.Interface().(time.Time); ok {
|
||||||
|
today := time.Now()
|
||||||
|
if today.Year() > date.Year() || today.YearDay() > date.YearDay() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
route := gin.Default()
|
||||||
|
|
||||||
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
|
v.RegisterValidation("bookabledate", bookableDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
route.GET("/bookable", getBookable)
|
||||||
|
route.Run(":8085")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBookable(c *gin.Context) {
|
||||||
|
var b Booking
|
||||||
|
if err := c.ShouldBindWith(&b, binding.Query); err == nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "Booking dates are valid!"})
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
|
}
|
||||||
|
}
|
BIN
vendor/github.com/gin-gonic/gin/examples/favicon/favicon.ico
generated
vendored
Normal file
BIN
vendor/github.com/gin-gonic/gin/examples/favicon/favicon.ico
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
17
vendor/github.com/gin-gonic/gin/examples/favicon/main.go
generated
vendored
Normal file
17
vendor/github.com/gin-gonic/gin/examples/favicon/main.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/thinkerou/favicon"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := gin.Default()
|
||||||
|
app.Use(favicon.New("./favicon.ico"))
|
||||||
|
app.GET("/ping", func(c *gin.Context) {
|
||||||
|
c.String(http.StatusOK, "Hello favicon.")
|
||||||
|
})
|
||||||
|
app.Run(":8080")
|
||||||
|
}
|
2
vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go
generated
vendored
2
vendor/github.com/gin-gonic/gin/examples/graceful-shutdown/close/server.go
generated
vendored
@ -41,5 +41,5 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Server exist")
|
log.Println("Server exiting")
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ func main() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// service connections
|
// service connections
|
||||||
if err := srv.ListenAndServe(); err != nil {
|
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
log.Printf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -44,5 +44,5 @@ func main() {
|
|||||||
if err := srv.Shutdown(ctx); err != nil {
|
if err := srv.Shutdown(ctx); err != nil {
|
||||||
log.Fatal("Server Shutdown:", err)
|
log.Fatal("Server Shutdown:", err)
|
||||||
}
|
}
|
||||||
log.Println("Server exist")
|
log.Println("Server exiting")
|
||||||
}
|
}
|
||||||
|
19
vendor/github.com/gin-gonic/gin/examples/grpc/README.md
generated
vendored
Normal file
19
vendor/github.com/gin-gonic/gin/examples/grpc/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
## How to run this example
|
||||||
|
|
||||||
|
1. run grpc server
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ go run grpc/server.go
|
||||||
|
```
|
||||||
|
|
||||||
|
2. run gin server
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ go run gin/main.go
|
||||||
|
```
|
||||||
|
|
||||||
|
3. use curl command to test it
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ curl -v 'http://localhost:8052/rest/n/thinkerou'
|
||||||
|
```
|
46
vendor/github.com/gin-gonic/gin/examples/grpc/gin/main.go
generated
vendored
Normal file
46
vendor/github.com/gin-gonic/gin/examples/grpc/gin/main.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
pb "github.com/gin-gonic/gin/examples/grpc/pb"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Set up a connection to the server.
|
||||||
|
conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("did not connect: %v", err)
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
client := pb.NewGreeterClient(conn)
|
||||||
|
|
||||||
|
// Set up a http setver.
|
||||||
|
r := gin.Default()
|
||||||
|
r.GET("/rest/n/:name", func(c *gin.Context) {
|
||||||
|
name := c.Param("name")
|
||||||
|
|
||||||
|
// Contact the server and print out its response.
|
||||||
|
req := &pb.HelloRequest{Name: name}
|
||||||
|
res, err := client.SayHello(c, req)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"result": fmt.Sprint(res.Message),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Run http server
|
||||||
|
if err := r.Run(":8052"); err != nil {
|
||||||
|
log.Fatalf("could not run server: %v", err)
|
||||||
|
}
|
||||||
|
}
|
34
vendor/github.com/gin-gonic/gin/examples/grpc/grpc/server.go
generated
vendored
Normal file
34
vendor/github.com/gin-gonic/gin/examples/grpc/grpc/server.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
pb "github.com/gin-gonic/gin/examples/grpc/pb"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/reflection"
|
||||||
|
)
|
||||||
|
|
||||||
|
// server is used to implement helloworld.GreeterServer.
|
||||||
|
type server struct{}
|
||||||
|
|
||||||
|
// SayHello implements helloworld.GreeterServer
|
||||||
|
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
|
||||||
|
return &pb.HelloReply{Message: "Hello " + in.Name}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
lis, err := net.Listen("tcp", ":50051")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to listen: %v", err)
|
||||||
|
}
|
||||||
|
s := grpc.NewServer()
|
||||||
|
pb.RegisterGreeterServer(s, &server{})
|
||||||
|
|
||||||
|
// Register reflection service on gRPC server.
|
||||||
|
reflection.Register(s)
|
||||||
|
if err := s.Serve(lis); err != nil {
|
||||||
|
log.Fatalf("failed to serve: %v", err)
|
||||||
|
}
|
||||||
|
}
|
151
vendor/github.com/gin-gonic/gin/examples/grpc/pb/helloworld.pb.go
generated
vendored
Normal file
151
vendor/github.com/gin-gonic/gin/examples/grpc/pb/helloworld.pb.go
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
// Code generated by protoc-gen-go.
|
||||||
|
// source: helloworld.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package helloworld is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
helloworld.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
HelloRequest
|
||||||
|
HelloReply
|
||||||
|
*/
|
||||||
|
package helloworld
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "golang.org/x/net/context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
// The request message containing the user's name.
|
||||||
|
type HelloRequest struct {
|
||||||
|
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HelloRequest) Reset() { *m = HelloRequest{} }
|
||||||
|
func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*HelloRequest) ProtoMessage() {}
|
||||||
|
func (*HelloRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
|
// The response message containing the greetings
|
||||||
|
type HelloReply struct {
|
||||||
|
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *HelloReply) Reset() { *m = HelloReply{} }
|
||||||
|
func (m *HelloReply) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*HelloReply) ProtoMessage() {}
|
||||||
|
func (*HelloReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*HelloRequest)(nil), "helloworld.HelloRequest")
|
||||||
|
proto.RegisterType((*HelloReply)(nil), "helloworld.HelloReply")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ context.Context
|
||||||
|
var _ grpc.ClientConn
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
const _ = grpc.SupportPackageIsVersion4
|
||||||
|
|
||||||
|
// Client API for Greeter service
|
||||||
|
|
||||||
|
type GreeterClient interface {
|
||||||
|
// Sends a greeting
|
||||||
|
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type greeterClient struct {
|
||||||
|
cc *grpc.ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGreeterClient(cc *grpc.ClientConn) GreeterClient {
|
||||||
|
return &greeterClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
|
||||||
|
out := new(HelloReply)
|
||||||
|
err := grpc.Invoke(ctx, "/helloworld.Greeter/SayHello", in, out, c.cc, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server API for Greeter service
|
||||||
|
|
||||||
|
type GreeterServer interface {
|
||||||
|
// Sends a greeting
|
||||||
|
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
|
||||||
|
s.RegisterService(&_Greeter_serviceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(HelloRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(GreeterServer).SayHello(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/helloworld.Greeter/SayHello",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _Greeter_serviceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "helloworld.Greeter",
|
||||||
|
HandlerType: (*GreeterServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "SayHello",
|
||||||
|
Handler: _Greeter_SayHello_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "helloworld.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("helloworld.proto", fileDescriptor0) }
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 174 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9,
|
||||||
|
0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x42, 0x88,
|
||||||
|
0x28, 0x29, 0x71, 0xf1, 0x78, 0x80, 0x78, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x42,
|
||||||
|
0x5c, 0x2c, 0x79, 0x89, 0xb9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x60, 0xb6, 0x92,
|
||||||
|
0x1a, 0x17, 0x17, 0x54, 0x4d, 0x41, 0x4e, 0xa5, 0x90, 0x04, 0x17, 0x7b, 0x6e, 0x6a, 0x71, 0x71,
|
||||||
|
0x62, 0x3a, 0x4c, 0x11, 0x8c, 0x6b, 0xe4, 0xc9, 0xc5, 0xee, 0x5e, 0x94, 0x9a, 0x5a, 0x92, 0x5a,
|
||||||
|
0x24, 0x64, 0xc7, 0xc5, 0x11, 0x9c, 0x58, 0x09, 0xd6, 0x25, 0x24, 0xa1, 0x87, 0xe4, 0x02, 0x64,
|
||||||
|
0xcb, 0xa4, 0xc4, 0xb0, 0xc8, 0x00, 0xad, 0x50, 0x62, 0x70, 0x32, 0xe0, 0x92, 0xce, 0xcc, 0xd7,
|
||||||
|
0x4b, 0x2f, 0x2a, 0x48, 0xd6, 0x4b, 0xad, 0x48, 0xcc, 0x2d, 0xc8, 0x49, 0x2d, 0x46, 0x52, 0xeb,
|
||||||
|
0xc4, 0x0f, 0x56, 0x1c, 0x0e, 0x62, 0x07, 0x80, 0xbc, 0x14, 0xc0, 0x98, 0xc4, 0x06, 0xf6, 0x9b,
|
||||||
|
0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xb7, 0xcd, 0xf2, 0xef, 0x00, 0x00, 0x00,
|
||||||
|
}
|
37
vendor/github.com/gin-gonic/gin/examples/grpc/pb/helloworld.proto
generated
vendored
Normal file
37
vendor/github.com/gin-gonic/gin/examples/grpc/pb/helloworld.proto
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright 2015 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_package = "io.grpc.examples.helloworld";
|
||||||
|
option java_outer_classname = "HelloWorldProto";
|
||||||
|
|
||||||
|
package helloworld;
|
||||||
|
|
||||||
|
// The greeting service definition.
|
||||||
|
service Greeter {
|
||||||
|
// Sends a greeting
|
||||||
|
rpc SayHello (HelloRequest) returns (HelloReply) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The request message containing the user's name.
|
||||||
|
message HelloRequest {
|
||||||
|
string name = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The response message containing the greetings
|
||||||
|
message HelloReply {
|
||||||
|
string message = 1;
|
||||||
|
}
|
1
vendor/github.com/gin-gonic/gin/examples/http-pusher/assets/app.js
generated
vendored
Normal file
1
vendor/github.com/gin-gonic/gin/examples/http-pusher/assets/app.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("http2 pusher");
|
41
vendor/github.com/gin-gonic/gin/examples/http-pusher/main.go
generated
vendored
Normal file
41
vendor/github.com/gin-gonic/gin/examples/http-pusher/main.go
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var html = template.Must(template.New("https").Parse(`
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Https Test</title>
|
||||||
|
<script src="/assets/app.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="color:red;">Welcome, Ginner!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`))
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := gin.Default()
|
||||||
|
r.Static("/assets", "./assets")
|
||||||
|
r.SetHTMLTemplate(html)
|
||||||
|
|
||||||
|
r.GET("/", func(c *gin.Context) {
|
||||||
|
if pusher := c.Writer.Pusher(); pusher != nil {
|
||||||
|
// use pusher.Push() to do server push
|
||||||
|
if err := pusher.Push("/assets/app.js", nil); err != nil {
|
||||||
|
log.Printf("Failed to push: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.HTML(200, "https", gin.H{
|
||||||
|
"status": "success",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Listen and Server in https://127.0.0.1:8080
|
||||||
|
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
|
||||||
|
}
|
15
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/ca.pem
generated
vendored
Normal file
15
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/ca.pem
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
|
||||||
|
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
|
||||||
|
aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
|
||||||
|
Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
|
||||||
|
YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
|
||||||
|
BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
|
||||||
|
+L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
|
||||||
|
g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
|
||||||
|
Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
|
||||||
|
HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
|
||||||
|
sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
|
||||||
|
oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
|
||||||
|
Dfcog5wrJytaQ6UA0wE=
|
||||||
|
-----END CERTIFICATE-----
|
16
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/server.key
generated
vendored
Normal file
16
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/server.key
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOHDFScoLCVJpYDD
|
||||||
|
M4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1BgzkWF+slf
|
||||||
|
3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd9N8YwbBY
|
||||||
|
AckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAECgYAn7qGnM2vbjJNBm0VZCkOkTIWm
|
||||||
|
V10okw7EPJrdL2mkre9NasghNXbE1y5zDshx5Nt3KsazKOxTT8d0Jwh/3KbaN+YY
|
||||||
|
tTCbKGW0pXDRBhwUHRcuRzScjli8Rih5UOCiZkhefUTcRb6xIhZJuQy71tjaSy0p
|
||||||
|
dHZRmYyBYO2YEQ8xoQJBAPrJPhMBkzmEYFtyIEqAxQ/o/A6E+E4w8i+KM7nQCK7q
|
||||||
|
K4JXzyXVAjLfyBZWHGM2uro/fjqPggGD6QH1qXCkI4MCQQDmdKeb2TrKRh5BY1LR
|
||||||
|
81aJGKcJ2XbcDu6wMZK4oqWbTX2KiYn9GB0woM6nSr/Y6iy1u145YzYxEV/iMwff
|
||||||
|
DJULAkB8B2MnyzOg0pNFJqBJuH29bKCcHa8gHJzqXhNO5lAlEbMK95p/P2Wi+4Hd
|
||||||
|
aiEIAF1BF326QJcvYKmwSmrORp85AkAlSNxRJ50OWrfMZnBgzVjDx3xG6KsFQVk2
|
||||||
|
ol6VhqL6dFgKUORFUWBvnKSyhjJxurlPEahV6oo6+A+mPhFY8eUvAkAZQyTdupP3
|
||||||
|
XEFQKctGz+9+gKkemDp7LBBMEMBXrGTLPhpEfcjv/7KPdnFHYmhYeBTBnuVmTVWe
|
||||||
|
F98XJ7tIFfJq
|
||||||
|
-----END PRIVATE KEY-----
|
16
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/server.pem
generated
vendored
Normal file
16
vendor/github.com/gin-gonic/gin/examples/http-pusher/testdata/server.pem
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIICnDCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
|
||||||
|
MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
|
||||||
|
dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTA0MDIyMDI0WhcNMjUxMTAx
|
||||||
|
MDIyMDI0WjBlMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV
|
||||||
|
BAcTB0NoaWNhZ28xFTATBgNVBAoTDEV4YW1wbGUsIENvLjEaMBgGA1UEAxQRKi50
|
||||||
|
ZXN0Lmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOHDFSco
|
||||||
|
LCVJpYDDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg
|
||||||
|
zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
|
||||||
|
9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
|
||||||
|
CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
|
||||||
|
em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
|
||||||
|
CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
|
||||||
|
hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
|
||||||
|
y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
|
||||||
|
-----END CERTIFICATE-----
|
18
vendor/github.com/gin-gonic/gin/examples/http2/README.md
generated
vendored
Normal file
18
vendor/github.com/gin-gonic/gin/examples/http2/README.md
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
## How to generate RSA private key and digital certificate
|
||||||
|
|
||||||
|
1. Install Openssl
|
||||||
|
|
||||||
|
Please visit https://github.com/openssl/openssl to get pkg and install.
|
||||||
|
|
||||||
|
2. Generate RSA private key
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ mkdir testdata
|
||||||
|
$ openssl genrsa -out ./testdata/server.key 2048
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Generate digital certificate
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ openssl req -new -x509 -key ./testdata/server.key -out ./testdata/server.pem -days 365
|
||||||
|
```
|
38
vendor/github.com/gin-gonic/gin/examples/http2/main.go
generated
vendored
Normal file
38
vendor/github.com/gin-gonic/gin/examples/http2/main.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
var html = template.Must(template.New("https").Parse(`
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Https Test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="color:red;">Welcome, Ginner!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`))
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logger := log.New(os.Stderr, "", 0)
|
||||||
|
logger.Println("[WARNING] DON'T USE THE EMBED CERTS FROM THIS EXAMPLE IN PRODUCTION ENVIRONMENT, GENERATE YOUR OWN!")
|
||||||
|
|
||||||
|
r := gin.Default()
|
||||||
|
r.SetHTMLTemplate(html)
|
||||||
|
|
||||||
|
r.GET("/welcome", func(c *gin.Context) {
|
||||||
|
c.HTML(http.StatusOK, "https", gin.H{
|
||||||
|
"status": "success",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Listen and Server in https://127.0.0.1:8080
|
||||||
|
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
|
||||||
|
}
|
15
vendor/github.com/gin-gonic/gin/examples/http2/testdata/ca.pem
generated
vendored
Normal file
15
vendor/github.com/gin-gonic/gin/examples/http2/testdata/ca.pem
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
|
||||||
|
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
|
||||||
|
aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
|
||||||
|
Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
|
||||||
|
YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
|
||||||
|
BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
|
||||||
|
+L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
|
||||||
|
g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
|
||||||
|
Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
|
||||||
|
HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
|
||||||
|
sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
|
||||||
|
oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
|
||||||
|
Dfcog5wrJytaQ6UA0wE=
|
||||||
|
-----END CERTIFICATE-----
|
16
vendor/github.com/gin-gonic/gin/examples/http2/testdata/server.key
generated
vendored
Normal file
16
vendor/github.com/gin-gonic/gin/examples/http2/testdata/server.key
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOHDFScoLCVJpYDD
|
||||||
|
M4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1BgzkWF+slf
|
||||||
|
3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd9N8YwbBY
|
||||||
|
AckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAECgYAn7qGnM2vbjJNBm0VZCkOkTIWm
|
||||||
|
V10okw7EPJrdL2mkre9NasghNXbE1y5zDshx5Nt3KsazKOxTT8d0Jwh/3KbaN+YY
|
||||||
|
tTCbKGW0pXDRBhwUHRcuRzScjli8Rih5UOCiZkhefUTcRb6xIhZJuQy71tjaSy0p
|
||||||
|
dHZRmYyBYO2YEQ8xoQJBAPrJPhMBkzmEYFtyIEqAxQ/o/A6E+E4w8i+KM7nQCK7q
|
||||||
|
K4JXzyXVAjLfyBZWHGM2uro/fjqPggGD6QH1qXCkI4MCQQDmdKeb2TrKRh5BY1LR
|
||||||
|
81aJGKcJ2XbcDu6wMZK4oqWbTX2KiYn9GB0woM6nSr/Y6iy1u145YzYxEV/iMwff
|
||||||
|
DJULAkB8B2MnyzOg0pNFJqBJuH29bKCcHa8gHJzqXhNO5lAlEbMK95p/P2Wi+4Hd
|
||||||
|
aiEIAF1BF326QJcvYKmwSmrORp85AkAlSNxRJ50OWrfMZnBgzVjDx3xG6KsFQVk2
|
||||||
|
ol6VhqL6dFgKUORFUWBvnKSyhjJxurlPEahV6oo6+A+mPhFY8eUvAkAZQyTdupP3
|
||||||
|
XEFQKctGz+9+gKkemDp7LBBMEMBXrGTLPhpEfcjv/7KPdnFHYmhYeBTBnuVmTVWe
|
||||||
|
F98XJ7tIFfJq
|
||||||
|
-----END PRIVATE KEY-----
|
16
vendor/github.com/gin-gonic/gin/examples/http2/testdata/server.pem
generated
vendored
Normal file
16
vendor/github.com/gin-gonic/gin/examples/http2/testdata/server.pem
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIICnDCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
|
||||||
|
MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
|
||||||
|
dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTA0MDIyMDI0WhcNMjUxMTAx
|
||||||
|
MDIyMDI0WjBlMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV
|
||||||
|
BAcTB0NoaWNhZ28xFTATBgNVBAoTDEV4YW1wbGUsIENvLjEaMBgGA1UEAxQRKi50
|
||||||
|
ZXN0Lmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOHDFSco
|
||||||
|
LCVJpYDDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg
|
||||||
|
zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
|
||||||
|
9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
|
||||||
|
CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
|
||||||
|
em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
|
||||||
|
CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
|
||||||
|
hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
|
||||||
|
y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
|
||||||
|
-----END CERTIFICATE-----
|
74
vendor/github.com/gin-gonic/gin/examples/multiple-service/main.go
generated
vendored
Normal file
74
vendor/github.com/gin-gonic/gin/examples/multiple-service/main.go
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
g errgroup.Group
|
||||||
|
)
|
||||||
|
|
||||||
|
func router01() http.Handler {
|
||||||
|
e := gin.New()
|
||||||
|
e.Use(gin.Recovery())
|
||||||
|
e.GET("/", func(c *gin.Context) {
|
||||||
|
c.JSON(
|
||||||
|
http.StatusOK,
|
||||||
|
gin.H{
|
||||||
|
"code": http.StatusOK,
|
||||||
|
"error": "Welcome server 01",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func router02() http.Handler {
|
||||||
|
e := gin.New()
|
||||||
|
e.Use(gin.Recovery())
|
||||||
|
e.GET("/", func(c *gin.Context) {
|
||||||
|
c.JSON(
|
||||||
|
http.StatusOK,
|
||||||
|
gin.H{
|
||||||
|
"code": http.StatusOK,
|
||||||
|
"error": "Welcome server 02",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
server01 := &http.Server{
|
||||||
|
Addr: ":8080",
|
||||||
|
Handler: router01(),
|
||||||
|
ReadTimeout: 5 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
server02 := &http.Server{
|
||||||
|
Addr: ":8081",
|
||||||
|
Handler: router02(),
|
||||||
|
ReadTimeout: 5 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
g.Go(func() error {
|
||||||
|
return server01.ListenAndServe()
|
||||||
|
})
|
||||||
|
|
||||||
|
g.Go(func() error {
|
||||||
|
return server02.ListenAndServe()
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := g.Wait(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
11
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go
generated
vendored
11
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -21,12 +22,12 @@ func rateLimit(c *gin.Context) {
|
|||||||
fmt.Println("ip blocked")
|
fmt.Println("ip blocked")
|
||||||
}
|
}
|
||||||
c.Abort()
|
c.Abort()
|
||||||
c.String(503, "you were automatically banned :)")
|
c.String(http.StatusServiceUnavailable, "you were automatically banned :)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func index(c *gin.Context) {
|
func index(c *gin.Context) {
|
||||||
c.Redirect(301, "/room/hn")
|
c.Redirect(http.StatusMovedPermanently, "/room/hn")
|
||||||
}
|
}
|
||||||
|
|
||||||
func roomGET(c *gin.Context) {
|
func roomGET(c *gin.Context) {
|
||||||
@ -38,7 +39,7 @@ func roomGET(c *gin.Context) {
|
|||||||
if len(nick) > 13 {
|
if len(nick) > 13 {
|
||||||
nick = nick[0:12] + "..."
|
nick = nick[0:12] + "..."
|
||||||
}
|
}
|
||||||
c.HTML(200, "room_login.templ.html", gin.H{
|
c.HTML(http.StatusOK, "room_login.templ.html", gin.H{
|
||||||
"roomid": roomid,
|
"roomid": roomid,
|
||||||
"nick": nick,
|
"nick": nick,
|
||||||
"timestamp": time.Now().Unix(),
|
"timestamp": time.Now().Unix(),
|
||||||
@ -55,7 +56,7 @@ func roomPOST(c *gin.Context) {
|
|||||||
validMessage := len(message) > 1 && len(message) < 200
|
validMessage := len(message) > 1 && len(message) < 200
|
||||||
validNick := len(nick) > 1 && len(nick) < 14
|
validNick := len(nick) > 1 && len(nick) < 14
|
||||||
if !validMessage || !validNick {
|
if !validMessage || !validNick {
|
||||||
c.JSON(400, gin.H{
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
"status": "failed",
|
"status": "failed",
|
||||||
"error": "the message or nickname is too long",
|
"error": "the message or nickname is too long",
|
||||||
})
|
})
|
||||||
@ -68,7 +69,7 @@ func roomPOST(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
messages.Add("inbound", 1)
|
messages.Add("inbound", 1)
|
||||||
room(roomid).Submit(post)
|
room(roomid).Submit(post)
|
||||||
c.JSON(200, post)
|
c.JSON(http.StatusOK, post)
|
||||||
}
|
}
|
||||||
|
|
||||||
func streamRoom(c *gin.Context) {
|
func streamRoom(c *gin.Context) {
|
||||||
|
4
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go
generated
vendored
4
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/stats.go
generated
vendored
@ -29,8 +29,8 @@ func statsWorker() {
|
|||||||
"timestamp": uint64(time.Now().Unix()),
|
"timestamp": uint64(time.Now().Unix()),
|
||||||
"HeapInuse": stats.HeapInuse,
|
"HeapInuse": stats.HeapInuse,
|
||||||
"StackInuse": stats.StackInuse,
|
"StackInuse": stats.StackInuse,
|
||||||
"Mallocs": (stats.Mallocs - lastMallocs),
|
"Mallocs": stats.Mallocs - lastMallocs,
|
||||||
"Frees": (stats.Frees - lastFrees),
|
"Frees": stats.Frees - lastFrees,
|
||||||
"Inbound": uint64(messages.Get("inbound")),
|
"Inbound": uint64(messages.Get("inbound")),
|
||||||
"Outbound": uint64(messages.Get("outbound")),
|
"Outbound": uint64(messages.Get("outbound")),
|
||||||
"Connected": connectedUsers(),
|
"Connected": connectedUsers(),
|
||||||
|
5
vendor/github.com/gin-gonic/gin/examples/realtime-chat/main.go
generated
vendored
5
vendor/github.com/gin-gonic/gin/examples/realtime-chat/main.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -34,7 +35,7 @@ func stream(c *gin.Context) {
|
|||||||
func roomGET(c *gin.Context) {
|
func roomGET(c *gin.Context) {
|
||||||
roomid := c.Param("roomid")
|
roomid := c.Param("roomid")
|
||||||
userid := fmt.Sprint(rand.Int31())
|
userid := fmt.Sprint(rand.Int31())
|
||||||
c.HTML(200, "chat_room", gin.H{
|
c.HTML(http.StatusOK, "chat_room", gin.H{
|
||||||
"roomid": roomid,
|
"roomid": roomid,
|
||||||
"userid": userid,
|
"userid": userid,
|
||||||
})
|
})
|
||||||
@ -46,7 +47,7 @@ func roomPOST(c *gin.Context) {
|
|||||||
message := c.PostForm("message")
|
message := c.PostForm("message")
|
||||||
room(roomid).Submit(userid + ": " + message)
|
room(roomid).Submit(userid + ": " + message)
|
||||||
|
|
||||||
c.JSON(200, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": message,
|
"message": message,
|
||||||
})
|
})
|
||||||
|
50
vendor/github.com/gin-gonic/gin/examples/struct-lvl-validations/README.md
generated
vendored
Normal file
50
vendor/github.com/gin-gonic/gin/examples/struct-lvl-validations/README.md
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
## Struct level validations
|
||||||
|
|
||||||
|
Validations can also be registered at the `struct` level when field level validations
|
||||||
|
don't make much sense. This can also be used to solve cross-field validation elegantly.
|
||||||
|
Additionally, it can be combined with tag validations. Struct Level validations run after
|
||||||
|
the structs tag validations.
|
||||||
|
|
||||||
|
### Example requests
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# Validation errors are generated for struct tags as well as at the struct level
|
||||||
|
$ curl -s -X POST http://localhost:8085/user \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{}' | jq
|
||||||
|
{
|
||||||
|
"error": "Key: 'User.Email' Error:Field validation for 'Email' failed on the 'required' tag\nKey: 'User.FirstName' Error:Field validation for 'FirstName' failed on the 'fnameorlname' tag\nKey: 'User.LastName' Error:Field validation for 'LastName' failed on the 'fnameorlname' tag",
|
||||||
|
"message": "User validation failed!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Validation fails at the struct level because neither first name nor last name are present
|
||||||
|
$ curl -s -X POST http://localhost:8085/user \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{"email": "george@vandaley.com"}' | jq
|
||||||
|
{
|
||||||
|
"error": "Key: 'User.FirstName' Error:Field validation for 'FirstName' failed on the 'fnameorlname' tag\nKey: 'User.LastName' Error:Field validation for 'LastName' failed on the 'fnameorlname' tag",
|
||||||
|
"message": "User validation failed!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# No validation errors when either first name or last name is present
|
||||||
|
$ curl -X POST http://localhost:8085/user \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{"fname": "George", "email": "george@vandaley.com"}'
|
||||||
|
{"message":"User validation successful."}
|
||||||
|
|
||||||
|
$ curl -X POST http://localhost:8085/user \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{"lname": "Contanza", "email": "george@vandaley.com"}'
|
||||||
|
{"message":"User validation successful."}
|
||||||
|
|
||||||
|
$ curl -X POST http://localhost:8085/user \
|
||||||
|
-H 'content-type: application/json' \
|
||||||
|
-d '{"fname": "George", "lname": "Costanza", "email": "george@vandaley.com"}'
|
||||||
|
{"message":"User validation successful."}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Useful links
|
||||||
|
|
||||||
|
- Validator docs - https://godoc.org/gopkg.in/go-playground/validator.v8#Validate.RegisterStructValidation
|
||||||
|
- Struct level example - https://github.com/go-playground/validator/blob/v8.18.2/examples/struct-level/struct_level.go
|
||||||
|
- Validator release notes - https://github.com/go-playground/validator/releases/tag/v8.7
|
64
vendor/github.com/gin-gonic/gin/examples/struct-lvl-validations/server.go
generated
vendored
Normal file
64
vendor/github.com/gin-gonic/gin/examples/struct-lvl-validations/server.go
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
validator "gopkg.in/go-playground/validator.v8"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User contains user information.
|
||||||
|
type User struct {
|
||||||
|
FirstName string `json:"fname"`
|
||||||
|
LastName string `json:"lname"`
|
||||||
|
Email string `binding:"required,email"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserStructLevelValidation contains custom struct level validations that don't always
|
||||||
|
// make sense at the field validation level. For example, this function validates that either
|
||||||
|
// FirstName or LastName exist; could have done that with a custom field validation but then
|
||||||
|
// would have had to add it to both fields duplicating the logic + overhead, this way it's
|
||||||
|
// only validated once.
|
||||||
|
//
|
||||||
|
// NOTE: you may ask why wouldn't not just do this outside of validator. Doing this way
|
||||||
|
// hooks right into validator and you can combine with validation tags and still have a
|
||||||
|
// common error output format.
|
||||||
|
func UserStructLevelValidation(v *validator.Validate, structLevel *validator.StructLevel) {
|
||||||
|
user := structLevel.CurrentStruct.Interface().(User)
|
||||||
|
|
||||||
|
if len(user.FirstName) == 0 && len(user.LastName) == 0 {
|
||||||
|
structLevel.ReportError(
|
||||||
|
reflect.ValueOf(user.FirstName), "FirstName", "fname", "fnameorlname",
|
||||||
|
)
|
||||||
|
structLevel.ReportError(
|
||||||
|
reflect.ValueOf(user.LastName), "LastName", "lname", "fnameorlname",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// plus can to more, even with different tag than "fnameorlname"
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
route := gin.Default()
|
||||||
|
|
||||||
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
|
v.RegisterStructValidation(UserStructLevelValidation, User{})
|
||||||
|
}
|
||||||
|
|
||||||
|
route.POST("/user", validateUser)
|
||||||
|
route.Run(":8085")
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateUser(c *gin.Context) {
|
||||||
|
var u User
|
||||||
|
if err := c.ShouldBindJSON(&u); err == nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "User validation successful."})
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"message": "User validation failed!",
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
32
vendor/github.com/gin-gonic/gin/examples/template/main.go
generated
vendored
Normal file
32
vendor/github.com/gin-gonic/gin/examples/template/main.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func formatAsDate(t time.Time) string {
|
||||||
|
year, month, day := t.Date()
|
||||||
|
return fmt.Sprintf("%d%02d/%02d", year, month, day)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
router := gin.Default()
|
||||||
|
router.Delims("{[{", "}]}")
|
||||||
|
router.SetFuncMap(template.FuncMap{
|
||||||
|
"formatAsDate": formatAsDate,
|
||||||
|
})
|
||||||
|
router.LoadHTMLFiles("../../testdata/template/raw.tmpl")
|
||||||
|
|
||||||
|
router.GET("/raw", func(c *gin.Context) {
|
||||||
|
c.HTML(http.StatusOK, "raw.tmpl", map[string]interface{}{
|
||||||
|
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
router.Run(":8080")
|
||||||
|
}
|
24
vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go
generated
vendored
24
vendor/github.com/gin-gonic/gin/examples/upload-file/multiple/main.go
generated
vendored
@ -2,35 +2,33 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
// Set a lower memory limit for multipart forms (default is 32 MiB)
|
||||||
|
router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||||
router.Static("/", "./public")
|
router.Static("/", "./public")
|
||||||
router.POST("/upload", func(c *gin.Context) {
|
router.POST("/upload", func(c *gin.Context) {
|
||||||
name := c.PostForm("name")
|
name := c.PostForm("name")
|
||||||
email := c.PostForm("email")
|
email := c.PostForm("email")
|
||||||
|
|
||||||
// Multipart form
|
// Multipart form
|
||||||
form, _ := c.MultipartForm()
|
form, err := c.MultipartForm()
|
||||||
|
if err != nil {
|
||||||
|
c.String(http.StatusBadRequest, fmt.Sprintf("get form err: %s", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
files := form.File["files"]
|
files := form.File["files"]
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
// Source
|
if err := c.SaveUploadedFile(file, file.Filename); err != nil {
|
||||||
src, _ := file.Open()
|
c.String(http.StatusBadRequest, fmt.Sprintf("upload file err: %s", err.Error()))
|
||||||
defer src.Close()
|
return
|
||||||
|
}
|
||||||
// Destination
|
|
||||||
dst, _ := os.Create(file.Filename)
|
|
||||||
defer dst.Close()
|
|
||||||
|
|
||||||
// Copy
|
|
||||||
io.Copy(dst, src)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.String(http.StatusOK, fmt.Sprintf("Uploaded successfully %d files with fields name=%s and email=%s.", len(files), name, email))
|
c.String(http.StatusOK, fmt.Sprintf("Uploaded successfully %d files with fields name=%s and email=%s.", len(files), name, email))
|
||||||
|
22
vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go
generated
vendored
22
vendor/github.com/gin-gonic/gin/examples/upload-file/single/main.go
generated
vendored
@ -2,31 +2,31 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
|
// Set a lower memory limit for multipart forms (default is 32 MiB)
|
||||||
|
router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||||
router.Static("/", "./public")
|
router.Static("/", "./public")
|
||||||
router.POST("/upload", func(c *gin.Context) {
|
router.POST("/upload", func(c *gin.Context) {
|
||||||
name := c.PostForm("name")
|
name := c.PostForm("name")
|
||||||
email := c.PostForm("email")
|
email := c.PostForm("email")
|
||||||
|
|
||||||
// Source
|
// Source
|
||||||
file, _ := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
src, _ := file.Open()
|
if err != nil {
|
||||||
defer src.Close()
|
c.String(http.StatusBadRequest, fmt.Sprintf("get form err: %s", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Destination
|
if err := c.SaveUploadedFile(file, file.Filename); err != nil {
|
||||||
dst, _ := os.Create(file.Filename)
|
c.String(http.StatusBadRequest, fmt.Sprintf("upload file err: %s", err.Error()))
|
||||||
defer dst.Close()
|
return
|
||||||
|
}
|
||||||
// Copy
|
|
||||||
io.Copy(dst, src)
|
|
||||||
|
|
||||||
c.String(http.StatusOK, fmt.Sprintf("File %s uploaded successfully with fields name=%s and email=%s.", file.Filename, name, email))
|
c.String(http.StatusOK, fmt.Sprintf("File %s uploaded successfully with fields name=%s and email=%s.", file.Filename, name, email))
|
||||||
})
|
})
|
||||||
|
19
vendor/github.com/gin-gonic/gin/fs.go
generated
vendored
19
vendor/github.com/gin-gonic/gin/fs.go
generated
vendored
@ -9,14 +9,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type onlyfilesFS struct {
|
||||||
onlyfilesFS struct {
|
fs http.FileSystem
|
||||||
fs http.FileSystem
|
}
|
||||||
}
|
|
||||||
neuteredReaddirFile struct {
|
type neuteredReaddirFile struct {
|
||||||
http.File
|
http.File
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
|
// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
|
||||||
// in router.Static().
|
// in router.Static().
|
||||||
@ -30,7 +29,7 @@ func Dir(root string, listDirectory bool) http.FileSystem {
|
|||||||
return &onlyfilesFS{fs}
|
return &onlyfilesFS{fs}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conforms to http.Filesystem
|
// Open conforms to http.Filesystem.
|
||||||
func (fs onlyfilesFS) Open(name string) (http.File, error) {
|
func (fs onlyfilesFS) Open(name string) (http.File, error) {
|
||||||
f, err := fs.fs.Open(name)
|
f, err := fs.fs.Open(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -39,7 +38,7 @@ func (fs onlyfilesFS) Open(name string) (http.File, error) {
|
|||||||
return neuteredReaddirFile{f}, nil
|
return neuteredReaddirFile{f}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overrides the http.File default implementation
|
// Readdir overrides the http.File default implementation.
|
||||||
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
|
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
|
||||||
// this disables directory listing
|
// this disables directory listing
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
299
vendor/github.com/gin-gonic/gin/gin.go
generated
vendored
299
vendor/github.com/gin-gonic/gin/gin.go
generated
vendored
@ -14,86 +14,96 @@ import (
|
|||||||
"github.com/gin-gonic/gin/render"
|
"github.com/gin-gonic/gin/render"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is Framework's version
|
const (
|
||||||
const Version = "v1.2"
|
// Version is Framework's version.
|
||||||
|
Version = "v1.3.0"
|
||||||
|
defaultMultipartMemory = 32 << 20 // 32 MB
|
||||||
|
)
|
||||||
|
|
||||||
var default404Body = []byte("404 page not found")
|
var (
|
||||||
var default405Body = []byte("405 method not allowed")
|
default404Body = []byte("404 page not found")
|
||||||
var defaultAppEngine bool
|
default405Body = []byte("405 method not allowed")
|
||||||
|
defaultAppEngine bool
|
||||||
|
)
|
||||||
|
|
||||||
type HandlerFunc func(*Context)
|
type HandlerFunc func(*Context)
|
||||||
type HandlersChain []HandlerFunc
|
type HandlersChain []HandlerFunc
|
||||||
|
|
||||||
// Last returns the last handler in the chain. ie. the last handler is the main own.
|
// Last returns the last handler in the chain. ie. the last handler is the main own.
|
||||||
func (c HandlersChain) Last() HandlerFunc {
|
func (c HandlersChain) Last() HandlerFunc {
|
||||||
length := len(c)
|
if length := len(c); length > 0 {
|
||||||
if length > 0 {
|
|
||||||
return c[length-1]
|
return c[length-1]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type RouteInfo struct {
|
||||||
RoutesInfo []RouteInfo
|
Method string
|
||||||
RouteInfo struct {
|
Path string
|
||||||
Method string
|
Handler string
|
||||||
Path string
|
}
|
||||||
Handler string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
|
type RoutesInfo []RouteInfo
|
||||||
// Create an instance of Engine, by using New() or Default()
|
|
||||||
Engine struct {
|
|
||||||
RouterGroup
|
|
||||||
delims render.Delims
|
|
||||||
HTMLRender render.HTMLRender
|
|
||||||
FuncMap template.FuncMap
|
|
||||||
allNoRoute HandlersChain
|
|
||||||
allNoMethod HandlersChain
|
|
||||||
noRoute HandlersChain
|
|
||||||
noMethod HandlersChain
|
|
||||||
pool sync.Pool
|
|
||||||
trees methodTrees
|
|
||||||
|
|
||||||
// Enables automatic redirection if the current route can't be matched but a
|
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
|
||||||
// handler for the path with (without) the trailing slash exists.
|
// Create an instance of Engine, by using New() or Default()
|
||||||
// For example if /foo/ is requested but a route only exists for /foo, the
|
type Engine struct {
|
||||||
// client is redirected to /foo with http status code 301 for GET requests
|
RouterGroup
|
||||||
// and 307 for all other request methods.
|
|
||||||
RedirectTrailingSlash bool
|
|
||||||
|
|
||||||
// If enabled, the router tries to fix the current request path, if no
|
// Enables automatic redirection if the current route can't be matched but a
|
||||||
// handle is registered for it.
|
// handler for the path with (without) the trailing slash exists.
|
||||||
// First superfluous path elements like ../ or // are removed.
|
// For example if /foo/ is requested but a route only exists for /foo, the
|
||||||
// Afterwards the router does a case-insensitive lookup of the cleaned path.
|
// client is redirected to /foo with http status code 301 for GET requests
|
||||||
// If a handle can be found for this route, the router makes a redirection
|
// and 307 for all other request methods.
|
||||||
// to the corrected path with status code 301 for GET requests and 307 for
|
RedirectTrailingSlash bool
|
||||||
// all other request methods.
|
|
||||||
// For example /FOO and /..//Foo could be redirected to /foo.
|
|
||||||
// RedirectTrailingSlash is independent of this option.
|
|
||||||
RedirectFixedPath bool
|
|
||||||
|
|
||||||
// If enabled, the router checks if another method is allowed for the
|
// If enabled, the router tries to fix the current request path, if no
|
||||||
// current route, if the current request can not be routed.
|
// handle is registered for it.
|
||||||
// If this is the case, the request is answered with 'Method Not Allowed'
|
// First superfluous path elements like ../ or // are removed.
|
||||||
// and HTTP status code 405.
|
// Afterwards the router does a case-insensitive lookup of the cleaned path.
|
||||||
// If no other Method is allowed, the request is delegated to the NotFound
|
// If a handle can be found for this route, the router makes a redirection
|
||||||
// handler.
|
// to the corrected path with status code 301 for GET requests and 307 for
|
||||||
HandleMethodNotAllowed bool
|
// all other request methods.
|
||||||
ForwardedByClientIP bool
|
// For example /FOO and /..//Foo could be redirected to /foo.
|
||||||
|
// RedirectTrailingSlash is independent of this option.
|
||||||
|
RedirectFixedPath bool
|
||||||
|
|
||||||
// #726 #755 If enabled, it will thrust some headers starting with
|
// If enabled, the router checks if another method is allowed for the
|
||||||
// 'X-AppEngine...' for better integration with that PaaS.
|
// current route, if the current request can not be routed.
|
||||||
AppEngine bool
|
// If this is the case, the request is answered with 'Method Not Allowed'
|
||||||
|
// and HTTP status code 405.
|
||||||
|
// If no other Method is allowed, the request is delegated to the NotFound
|
||||||
|
// handler.
|
||||||
|
HandleMethodNotAllowed bool
|
||||||
|
ForwardedByClientIP bool
|
||||||
|
|
||||||
// If enabled, the url.RawPath will be used to find parameters.
|
// #726 #755 If enabled, it will thrust some headers starting with
|
||||||
UseRawPath bool
|
// 'X-AppEngine...' for better integration with that PaaS.
|
||||||
// If true, the path value will be unescaped.
|
AppEngine bool
|
||||||
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
|
|
||||||
// as url.Path gonna be used, which is already unescaped.
|
// If enabled, the url.RawPath will be used to find parameters.
|
||||||
UnescapePathValues bool
|
UseRawPath bool
|
||||||
}
|
|
||||||
)
|
// If true, the path value will be unescaped.
|
||||||
|
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
|
||||||
|
// as url.Path gonna be used, which is already unescaped.
|
||||||
|
UnescapePathValues bool
|
||||||
|
|
||||||
|
// Value of 'maxMemory' param that is given to http.Request's ParseMultipartForm
|
||||||
|
// method call.
|
||||||
|
MaxMultipartMemory int64
|
||||||
|
|
||||||
|
delims render.Delims
|
||||||
|
secureJsonPrefix string
|
||||||
|
HTMLRender render.HTMLRender
|
||||||
|
FuncMap template.FuncMap
|
||||||
|
allNoRoute HandlersChain
|
||||||
|
allNoMethod HandlersChain
|
||||||
|
noRoute HandlersChain
|
||||||
|
noMethod HandlersChain
|
||||||
|
pool sync.Pool
|
||||||
|
trees methodTrees
|
||||||
|
}
|
||||||
|
|
||||||
var _ IRouter = &Engine{}
|
var _ IRouter = &Engine{}
|
||||||
|
|
||||||
@ -121,8 +131,10 @@ func New() *Engine {
|
|||||||
AppEngine: defaultAppEngine,
|
AppEngine: defaultAppEngine,
|
||||||
UseRawPath: false,
|
UseRawPath: false,
|
||||||
UnescapePathValues: true,
|
UnescapePathValues: true,
|
||||||
|
MaxMultipartMemory: defaultMultipartMemory,
|
||||||
trees: make(methodTrees, 0, 9),
|
trees: make(methodTrees, 0, 9),
|
||||||
delims: render.Delims{"{{", "}}"},
|
delims: render.Delims{Left: "{{", Right: "}}"},
|
||||||
|
secureJsonPrefix: "while(1);",
|
||||||
}
|
}
|
||||||
engine.RouterGroup.engine = engine
|
engine.RouterGroup.engine = engine
|
||||||
engine.pool.New = func() interface{} {
|
engine.pool.New = func() interface{} {
|
||||||
@ -133,6 +145,7 @@ func New() *Engine {
|
|||||||
|
|
||||||
// Default returns an Engine instance with the Logger and Recovery middleware already attached.
|
// Default returns an Engine instance with the Logger and Recovery middleware already attached.
|
||||||
func Default() *Engine {
|
func Default() *Engine {
|
||||||
|
debugPrintWARNINGDefault()
|
||||||
engine := New()
|
engine := New()
|
||||||
engine.Use(Logger(), Recovery())
|
engine.Use(Logger(), Recovery())
|
||||||
return engine
|
return engine
|
||||||
@ -143,29 +156,45 @@ func (engine *Engine) allocateContext() *Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) Delims(left, right string) *Engine {
|
func (engine *Engine) Delims(left, right string) *Engine {
|
||||||
engine.delims = render.Delims{left, right}
|
engine.delims = render.Delims{Left: left, Right: right}
|
||||||
return engine
|
return engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) LoadHTMLGlob(pattern string) {
|
// SecureJsonPrefix sets the secureJsonPrefix used in Context.SecureJSON.
|
||||||
if IsDebugging() {
|
func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {
|
||||||
debugPrintLoadTemplate(template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseGlob(pattern)))
|
engine.secureJsonPrefix = prefix
|
||||||
engine.HTMLRender = render.HTMLDebug{Glob: pattern, FuncMap: engine.FuncMap, Delims: engine.delims}
|
return engine
|
||||||
} else {
|
|
||||||
templ := template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseGlob(pattern))
|
|
||||||
engine.SetHTMLTemplate(templ)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadHTMLGlob loads HTML files identified by glob pattern
|
||||||
|
// and associates the result with HTML renderer.
|
||||||
|
func (engine *Engine) LoadHTMLGlob(pattern string) {
|
||||||
|
left := engine.delims.Left
|
||||||
|
right := engine.delims.Right
|
||||||
|
templ := template.Must(template.New("").Delims(left, right).Funcs(engine.FuncMap).ParseGlob(pattern))
|
||||||
|
|
||||||
|
if IsDebugging() {
|
||||||
|
debugPrintLoadTemplate(templ)
|
||||||
|
engine.HTMLRender = render.HTMLDebug{Glob: pattern, FuncMap: engine.FuncMap, Delims: engine.delims}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.SetHTMLTemplate(templ)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadHTMLFiles loads a slice of HTML files
|
||||||
|
// and associates the result with HTML renderer.
|
||||||
func (engine *Engine) LoadHTMLFiles(files ...string) {
|
func (engine *Engine) LoadHTMLFiles(files ...string) {
|
||||||
if IsDebugging() {
|
if IsDebugging() {
|
||||||
engine.HTMLRender = render.HTMLDebug{Files: files, FuncMap: engine.FuncMap, Delims: engine.delims}
|
engine.HTMLRender = render.HTMLDebug{Files: files, FuncMap: engine.FuncMap, Delims: engine.delims}
|
||||||
} else {
|
return
|
||||||
templ := template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseFiles(files...))
|
|
||||||
engine.SetHTMLTemplate(templ)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templ := template.Must(template.New("").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseFiles(files...))
|
||||||
|
engine.SetHTMLTemplate(templ)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetHTMLTemplate associate a template with HTML renderer.
|
||||||
func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
|
func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
|
||||||
if len(engine.trees) > 0 {
|
if len(engine.trees) > 0 {
|
||||||
debugPrintWARNINGSetHTMLTemplate()
|
debugPrintWARNINGSetHTMLTemplate()
|
||||||
@ -174,6 +203,7 @@ func (engine *Engine) SetHTMLTemplate(templ *template.Template) {
|
|||||||
engine.HTMLRender = render.HTMLProduction{Template: templ.Funcs(engine.FuncMap)}
|
engine.HTMLRender = render.HTMLProduction{Template: templ.Funcs(engine.FuncMap)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetFuncMap sets the FuncMap used for template.FuncMap.
|
||||||
func (engine *Engine) SetFuncMap(funcMap template.FuncMap) {
|
func (engine *Engine) SetFuncMap(funcMap template.FuncMap) {
|
||||||
engine.FuncMap = funcMap
|
engine.FuncMap = funcMap
|
||||||
}
|
}
|
||||||
@ -184,7 +214,7 @@ func (engine *Engine) NoRoute(handlers ...HandlerFunc) {
|
|||||||
engine.rebuild404Handlers()
|
engine.rebuild404Handlers()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoMethod sets the handlers called when... TODO
|
// NoMethod sets the handlers called when... TODO.
|
||||||
func (engine *Engine) NoMethod(handlers ...HandlerFunc) {
|
func (engine *Engine) NoMethod(handlers ...HandlerFunc) {
|
||||||
engine.noMethod = handlers
|
engine.noMethod = handlers
|
||||||
engine.rebuild405Handlers()
|
engine.rebuild405Handlers()
|
||||||
@ -210,7 +240,7 @@ func (engine *Engine) rebuild405Handlers() {
|
|||||||
|
|
||||||
func (engine *Engine) addRoute(method, path string, handlers HandlersChain) {
|
func (engine *Engine) addRoute(method, path string, handlers HandlersChain) {
|
||||||
assert1(path[0] == '/', "path must begin with '/'")
|
assert1(path[0] == '/', "path must begin with '/'")
|
||||||
assert1(len(method) > 0, "HTTP method can not be empty")
|
assert1(method != "", "HTTP method can not be empty")
|
||||||
assert1(len(handlers) > 0, "there must be at least one handler")
|
assert1(len(handlers) > 0, "there must be at least one handler")
|
||||||
|
|
||||||
debugPrintRoute(method, path, handlers)
|
debugPrintRoute(method, path, handlers)
|
||||||
@ -261,7 +291,7 @@ func (engine *Engine) Run(addr ...string) (err error) {
|
|||||||
// RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests.
|
// RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests.
|
||||||
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
||||||
// Note: this method will block the calling goroutine indefinitely unless an error happens.
|
// Note: this method will block the calling goroutine indefinitely unless an error happens.
|
||||||
func (engine *Engine) RunTLS(addr string, certFile string, keyFile string) (err error) {
|
func (engine *Engine) RunTLS(addr, certFile, keyFile string) (err error) {
|
||||||
debugPrint("Listening and serving HTTPS on %s\n", addr)
|
debugPrint("Listening and serving HTTPS on %s\n", addr)
|
||||||
defer func() { debugPrintError(err) }()
|
defer func() { debugPrintError(err) }()
|
||||||
|
|
||||||
@ -286,7 +316,7 @@ func (engine *Engine) RunUnix(file string) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conforms to the http.Handler interface.
|
// ServeHTTP conforms to the http.Handler interface.
|
||||||
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
c := engine.pool.Get().(*Context)
|
c := engine.pool.Get().(*Context)
|
||||||
c.writermem.reset(w)
|
c.writermem.reset(w)
|
||||||
@ -298,8 +328,8 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
engine.pool.Put(c)
|
engine.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-enter a context that has been rewritten.
|
// HandleContext re-enter a context that has been rewritten.
|
||||||
// This can be done by setting c.Request.Path to your new target.
|
// This can be done by setting c.Request.URL.Path to your new target.
|
||||||
// Disclaimer: You can loop yourself to death with this, use wisely.
|
// Disclaimer: You can loop yourself to death with this, use wisely.
|
||||||
func (engine *Engine) HandleContext(c *Context) {
|
func (engine *Engine) HandleContext(c *Context) {
|
||||||
c.reset()
|
c.reset()
|
||||||
@ -307,59 +337,57 @@ func (engine *Engine) HandleContext(c *Context) {
|
|||||||
engine.pool.Put(c)
|
engine.pool.Put(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) handleHTTPRequest(context *Context) {
|
func (engine *Engine) handleHTTPRequest(c *Context) {
|
||||||
httpMethod := context.Request.Method
|
httpMethod := c.Request.Method
|
||||||
var path string
|
path := c.Request.URL.Path
|
||||||
var unescape bool
|
unescape := false
|
||||||
if engine.UseRawPath && len(context.Request.URL.RawPath) > 0 {
|
if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
|
||||||
path = context.Request.URL.RawPath
|
path = c.Request.URL.RawPath
|
||||||
unescape = engine.UnescapePathValues
|
unescape = engine.UnescapePathValues
|
||||||
} else {
|
|
||||||
path = context.Request.URL.Path
|
|
||||||
unescape = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find root of the tree for the given HTTP method
|
// Find root of the tree for the given HTTP method
|
||||||
t := engine.trees
|
t := engine.trees
|
||||||
for i, tl := 0, len(t); i < tl; i++ {
|
for i, tl := 0, len(t); i < tl; i++ {
|
||||||
if t[i].method == httpMethod {
|
if t[i].method != httpMethod {
|
||||||
root := t[i].root
|
continue
|
||||||
// Find route in tree
|
}
|
||||||
handlers, params, tsr := root.getValue(path, context.Params, unescape)
|
root := t[i].root
|
||||||
if handlers != nil {
|
// Find route in tree
|
||||||
context.handlers = handlers
|
handlers, params, tsr := root.getValue(path, c.Params, unescape)
|
||||||
context.Params = params
|
if handlers != nil {
|
||||||
context.Next()
|
c.handlers = handlers
|
||||||
context.writermem.WriteHeaderNow()
|
c.Params = params
|
||||||
|
c.Next()
|
||||||
|
c.writermem.WriteHeaderNow()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if httpMethod != "CONNECT" && path != "/" {
|
||||||
|
if tsr && engine.RedirectTrailingSlash {
|
||||||
|
redirectTrailingSlash(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if httpMethod != "CONNECT" && path != "/" {
|
if engine.RedirectFixedPath && redirectFixedPath(c, root, engine.RedirectFixedPath) {
|
||||||
if tsr && engine.RedirectTrailingSlash {
|
return
|
||||||
redirectTrailingSlash(context)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if engine.RedirectFixedPath && redirectFixedPath(context, root, engine.RedirectFixedPath) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: unit test
|
|
||||||
if engine.HandleMethodNotAllowed {
|
if engine.HandleMethodNotAllowed {
|
||||||
for _, tree := range engine.trees {
|
for _, tree := range engine.trees {
|
||||||
if tree.method != httpMethod {
|
if tree.method == httpMethod {
|
||||||
if handlers, _, _ := tree.root.getValue(path, nil, unescape); handlers != nil {
|
continue
|
||||||
context.handlers = engine.allNoMethod
|
}
|
||||||
serveError(context, 405, default405Body)
|
if handlers, _, _ := tree.root.getValue(path, nil, unescape); handlers != nil {
|
||||||
return
|
c.handlers = engine.allNoMethod
|
||||||
}
|
serveError(c, http.StatusMethodNotAllowed, default405Body)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.handlers = engine.allNoRoute
|
c.handlers = engine.allNoRoute
|
||||||
serveError(context, 404, default404Body)
|
serveError(c, http.StatusNotFound, default404Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
var mimePlain = []string{MIMEPlain}
|
var mimePlain = []string{MIMEPlain}
|
||||||
@ -367,28 +395,29 @@ var mimePlain = []string{MIMEPlain}
|
|||||||
func serveError(c *Context, code int, defaultMessage []byte) {
|
func serveError(c *Context, code int, defaultMessage []byte) {
|
||||||
c.writermem.status = code
|
c.writermem.status = code
|
||||||
c.Next()
|
c.Next()
|
||||||
if !c.writermem.Written() {
|
if c.writermem.Written() {
|
||||||
if c.writermem.Status() == code {
|
return
|
||||||
c.writermem.Header()["Content-Type"] = mimePlain
|
|
||||||
c.Writer.Write(defaultMessage)
|
|
||||||
} else {
|
|
||||||
c.writermem.WriteHeaderNow()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if c.writermem.Status() == code {
|
||||||
|
c.writermem.Header()["Content-Type"] = mimePlain
|
||||||
|
c.Writer.Write(defaultMessage)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.writermem.WriteHeaderNow()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func redirectTrailingSlash(c *Context) {
|
func redirectTrailingSlash(c *Context) {
|
||||||
req := c.Request
|
req := c.Request
|
||||||
path := req.URL.Path
|
path := req.URL.Path
|
||||||
code := 301 // Permanent redirect, request with GET method
|
code := http.StatusMovedPermanently // Permanent redirect, request with GET method
|
||||||
if req.Method != "GET" {
|
if req.Method != "GET" {
|
||||||
code = 307
|
code = http.StatusTemporaryRedirect
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(path) > 1 && path[len(path)-1] == '/' {
|
req.URL.Path = path + "/"
|
||||||
req.URL.Path = path[:len(path)-1]
|
if length := len(path); length > 1 && path[length-1] == '/' {
|
||||||
} else {
|
req.URL.Path = path[:length-1]
|
||||||
req.URL.Path = path + "/"
|
|
||||||
}
|
}
|
||||||
debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
|
debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
|
||||||
http.Redirect(c.Writer, req, req.URL.String(), code)
|
http.Redirect(c.Writer, req, req.URL.String(), code)
|
||||||
@ -399,14 +428,10 @@ func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
|
|||||||
req := c.Request
|
req := c.Request
|
||||||
path := req.URL.Path
|
path := req.URL.Path
|
||||||
|
|
||||||
fixedPath, found := root.findCaseInsensitivePath(
|
if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(path), trailingSlash); ok {
|
||||||
cleanPath(path),
|
code := http.StatusMovedPermanently // Permanent redirect, request with GET method
|
||||||
trailingSlash,
|
|
||||||
)
|
|
||||||
if found {
|
|
||||||
code := 301 // Permanent redirect, request with GET method
|
|
||||||
if req.Method != "GET" {
|
if req.Method != "GET" {
|
||||||
code = 307
|
code = http.StatusTemporaryRedirect
|
||||||
}
|
}
|
||||||
req.URL.Path = string(fixedPath)
|
req.URL.Path = string(fixedPath)
|
||||||
debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
|
debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
|
||||||
|
42
vendor/github.com/gin-gonic/gin/ginS/gins.go
generated
vendored
42
vendor/github.com/gin-gonic/gin/ginS/gins.go
generated
vendored
@ -9,15 +9,15 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
. "github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
var internalEngine *Engine
|
var internalEngine *gin.Engine
|
||||||
|
|
||||||
func engine() *Engine {
|
func engine() *gin.Engine {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
internalEngine = Default()
|
internalEngine = gin.Default()
|
||||||
})
|
})
|
||||||
return internalEngine
|
return internalEngine
|
||||||
}
|
}
|
||||||
@ -35,65 +35,65 @@ func SetHTMLTemplate(templ *template.Template) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NoRoute adds handlers for NoRoute. It return a 404 code by default.
|
// NoRoute adds handlers for NoRoute. It return a 404 code by default.
|
||||||
func NoRoute(handlers ...HandlerFunc) {
|
func NoRoute(handlers ...gin.HandlerFunc) {
|
||||||
engine().NoRoute(handlers...)
|
engine().NoRoute(handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoMethod sets the handlers called when... TODO
|
// NoMethod sets the handlers called when... TODO
|
||||||
func NoMethod(handlers ...HandlerFunc) {
|
func NoMethod(handlers ...gin.HandlerFunc) {
|
||||||
engine().NoMethod(handlers...)
|
engine().NoMethod(handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group creates a new router group. You should add all the routes that have common middlwares or the same path prefix.
|
// Group creates a new router group. You should add all the routes that have common middlwares or the same path prefix.
|
||||||
// For example, all the routes that use a common middlware for authorization could be grouped.
|
// For example, all the routes that use a common middlware for authorization could be grouped.
|
||||||
func Group(relativePath string, handlers ...HandlerFunc) *RouterGroup {
|
func Group(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup {
|
||||||
return engine().Group(relativePath, handlers...)
|
return engine().Group(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Handle(httpMethod, relativePath string, handlers ...HandlerFunc) IRoutes {
|
func Handle(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().Handle(httpMethod, relativePath, handlers...)
|
return engine().Handle(httpMethod, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST is a shortcut for router.Handle("POST", path, handle)
|
// POST is a shortcut for router.Handle("POST", path, handle)
|
||||||
func POST(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func POST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().POST(relativePath, handlers...)
|
return engine().POST(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET is a shortcut for router.Handle("GET", path, handle)
|
// GET is a shortcut for router.Handle("GET", path, handle)
|
||||||
func GET(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func GET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().GET(relativePath, handlers...)
|
return engine().GET(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE is a shortcut for router.Handle("DELETE", path, handle)
|
// DELETE is a shortcut for router.Handle("DELETE", path, handle)
|
||||||
func DELETE(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func DELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().DELETE(relativePath, handlers...)
|
return engine().DELETE(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATCH is a shortcut for router.Handle("PATCH", path, handle)
|
// PATCH is a shortcut for router.Handle("PATCH", path, handle)
|
||||||
func PATCH(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func PATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().PATCH(relativePath, handlers...)
|
return engine().PATCH(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PUT is a shortcut for router.Handle("PUT", path, handle)
|
// PUT is a shortcut for router.Handle("PUT", path, handle)
|
||||||
func PUT(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func PUT(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().PUT(relativePath, handlers...)
|
return engine().PUT(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle)
|
// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle)
|
||||||
func OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func OPTIONS(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().OPTIONS(relativePath, handlers...)
|
return engine().OPTIONS(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HEAD is a shortcut for router.Handle("HEAD", path, handle)
|
// HEAD is a shortcut for router.Handle("HEAD", path, handle)
|
||||||
func HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func HEAD(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().HEAD(relativePath, handlers...)
|
return engine().HEAD(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Any(relativePath string, handlers ...HandlerFunc) IRoutes {
|
func Any(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().Any(relativePath, handlers...)
|
return engine().Any(relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func StaticFile(relativePath, filepath string) IRoutes {
|
func StaticFile(relativePath, filepath string) gin.IRoutes {
|
||||||
return engine().StaticFile(relativePath, filepath)
|
return engine().StaticFile(relativePath, filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,18 +103,18 @@ func StaticFile(relativePath, filepath string) IRoutes {
|
|||||||
// To use the operating system's file system implementation,
|
// To use the operating system's file system implementation,
|
||||||
// use :
|
// use :
|
||||||
// router.Static("/static", "/var/www")
|
// router.Static("/static", "/var/www")
|
||||||
func Static(relativePath, root string) IRoutes {
|
func Static(relativePath, root string) gin.IRoutes {
|
||||||
return engine().Static(relativePath, root)
|
return engine().Static(relativePath, root)
|
||||||
}
|
}
|
||||||
|
|
||||||
func StaticFS(relativePath string, fs http.FileSystem) IRoutes {
|
func StaticFS(relativePath string, fs http.FileSystem) gin.IRoutes {
|
||||||
return engine().StaticFS(relativePath, fs)
|
return engine().StaticFS(relativePath, fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use attachs a global middleware to the router. ie. the middlewares attached though Use() will be
|
// Use attachs a global middleware to the router. ie. the middlewares attached though Use() will be
|
||||||
// included in the handlers chain for every single request. Even 404, 405, static files...
|
// included in the handlers chain for every single request. Even 404, 405, static files...
|
||||||
// For example, this is the right place for a logger or error management middleware.
|
// For example, this is the right place for a logger or error management middleware.
|
||||||
func Use(middlewares ...HandlerFunc) IRoutes {
|
func Use(middlewares ...gin.HandlerFunc) gin.IRoutes {
|
||||||
return engine().Use(middlewares...)
|
return engine().Use(middlewares...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ func Run(addr ...string) (err error) {
|
|||||||
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
|
// RunTLS : The router is attached to a http.Server and starts listening and serving HTTPS requests.
|
||||||
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
|
||||||
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
|
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
|
||||||
func RunTLS(addr string, certFile string, keyFile string) (err error) {
|
func RunTLS(addr, certFile, keyFile string) (err error) {
|
||||||
return engine().RunTLS(addr, certFile, keyFile)
|
return engine().RunTLS(addr, certFile, keyFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/github.com/gin-gonic/gin/gin_integration_test.go
generated
vendored
2
vendor/github.com/gin-gonic/gin/gin_integration_test.go
generated
vendored
@ -94,7 +94,7 @@ func TestUnixSocket(t *testing.T) {
|
|||||||
c, err := net.Dial("unix", "/tmp/unix_unit_test")
|
c, err := net.Dial("unix", "/tmp/unix_unit_test")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
fmt.Fprintf(c, "GET /example HTTP/1.0\r\n\r\n")
|
fmt.Fprint(c, "GET /example HTTP/1.0\r\n\r\n")
|
||||||
scanner := bufio.NewScanner(c)
|
scanner := bufio.NewScanner(c)
|
||||||
var response string
|
var response string
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
136
vendor/github.com/gin-gonic/gin/gin_test.go
generated
vendored
136
vendor/github.com/gin-gonic/gin/gin_test.go
generated
vendored
@ -5,6 +5,7 @@
|
|||||||
package gin
|
package gin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -21,15 +22,15 @@ func formatAsDate(t time.Time) string {
|
|||||||
return fmt.Sprintf("%d/%02d/%02d", year, month, day)
|
return fmt.Sprintf("%d/%02d/%02d", year, month, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupHTMLFiles(t *testing.T) func() {
|
func setupHTMLFiles(t *testing.T, mode string, tls bool) func() {
|
||||||
go func() {
|
go func() {
|
||||||
SetMode(TestMode)
|
SetMode(mode)
|
||||||
router := New()
|
router := New()
|
||||||
router.Delims("{[{", "}]}")
|
router.Delims("{[{", "}]}")
|
||||||
router.SetFuncMap(template.FuncMap{
|
router.SetFuncMap(template.FuncMap{
|
||||||
"formatAsDate": formatAsDate,
|
"formatAsDate": formatAsDate,
|
||||||
})
|
})
|
||||||
router.LoadHTMLFiles("./fixtures/basic/hello.tmpl", "./fixtures/basic/raw.tmpl")
|
router.LoadHTMLFiles("./testdata/template/hello.tmpl", "./testdata/template/raw.tmpl")
|
||||||
router.GET("/test", func(c *Context) {
|
router.GET("/test", func(c *Context) {
|
||||||
c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})
|
c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})
|
||||||
})
|
})
|
||||||
@ -38,22 +39,27 @@ func setupHTMLFiles(t *testing.T) func() {
|
|||||||
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
|
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
router.Run(":8888")
|
if tls {
|
||||||
|
// these files generated by `go run $GOROOT/src/crypto/tls/generate_cert.go --host 127.0.0.1`
|
||||||
|
router.RunTLS(":9999", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem")
|
||||||
|
} else {
|
||||||
|
router.Run(":8888")
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
t.Log("waiting 1 second for server startup")
|
t.Log("waiting 1 second for server startup")
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
return func() {}
|
return func() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupHTMLGlob(t *testing.T) func() {
|
func setupHTMLGlob(t *testing.T, mode string, tls bool) func() {
|
||||||
go func() {
|
go func() {
|
||||||
SetMode(DebugMode)
|
SetMode(mode)
|
||||||
router := New()
|
router := New()
|
||||||
router.Delims("{[{", "}]}")
|
router.Delims("{[{", "}]}")
|
||||||
router.SetFuncMap(template.FuncMap{
|
router.SetFuncMap(template.FuncMap{
|
||||||
"formatAsDate": formatAsDate,
|
"formatAsDate": formatAsDate,
|
||||||
})
|
})
|
||||||
router.LoadHTMLGlob("./fixtures/basic/*")
|
router.LoadHTMLGlob("./testdata/template/*")
|
||||||
router.GET("/test", func(c *Context) {
|
router.GET("/test", func(c *Context) {
|
||||||
c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})
|
c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})
|
||||||
})
|
})
|
||||||
@ -62,16 +68,20 @@ func setupHTMLGlob(t *testing.T) func() {
|
|||||||
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
|
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
router.Run(":8888")
|
if tls {
|
||||||
|
// these files generated by `go run $GOROOT/src/crypto/tls/generate_cert.go --host 127.0.0.1`
|
||||||
|
router.RunTLS(":9999", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem")
|
||||||
|
} else {
|
||||||
|
router.Run(":8888")
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
t.Log("waiting 1 second for server startup")
|
t.Log("waiting 1 second for server startup")
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
return func() {}
|
return func() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
|
||||||
func TestLoadHTMLGlob(t *testing.T) {
|
func TestLoadHTMLGlob(t *testing.T) {
|
||||||
td := setupHTMLGlob(t)
|
td := setupHTMLGlob(t, DebugMode, false)
|
||||||
res, err := http.Get("http://127.0.0.1:8888/test")
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -83,9 +93,55 @@ func TestLoadHTMLGlob(t *testing.T) {
|
|||||||
td()
|
td()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLGlob2(t *testing.T) {
|
||||||
|
td := setupHTMLGlob(t, TestMode, false)
|
||||||
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLGlob3(t *testing.T) {
|
||||||
|
td := setupHTMLGlob(t, ReleaseMode, false)
|
||||||
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLGlobUsingTLS(t *testing.T) {
|
||||||
|
td := setupHTMLGlob(t, DebugMode, true)
|
||||||
|
// Use InsecureSkipVerify for avoiding `x509: certificate signed by unknown authority` error
|
||||||
|
tr := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
client := &http.Client{Transport: tr}
|
||||||
|
res, err := client.Get("https://127.0.0.1:9999/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
func TestLoadHTMLGlobFromFuncMap(t *testing.T) {
|
func TestLoadHTMLGlobFromFuncMap(t *testing.T) {
|
||||||
time.Now()
|
time.Now()
|
||||||
td := setupHTMLGlob(t)
|
td := setupHTMLGlob(t, DebugMode, false)
|
||||||
res, err := http.Get("http://127.0.0.1:8888/raw")
|
res, err := http.Get("http://127.0.0.1:8888/raw")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -97,9 +153,6 @@ func TestLoadHTMLGlobFromFuncMap(t *testing.T) {
|
|||||||
td()
|
td()
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (engine *Engine) LoadHTMLFiles(files ...string) {
|
|
||||||
// func (engine *Engine) RunTLS(addr string, cert string, key string) error {
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
SetMode(TestMode)
|
SetMode(TestMode)
|
||||||
}
|
}
|
||||||
@ -117,17 +170,17 @@ func TestCreateEngine(t *testing.T) {
|
|||||||
// router.LoadHTMLGlob("*.testtmpl")
|
// router.LoadHTMLGlob("*.testtmpl")
|
||||||
// r := router.HTMLRender.(render.HTMLDebug)
|
// r := router.HTMLRender.(render.HTMLDebug)
|
||||||
// assert.Empty(t, r.Files)
|
// assert.Empty(t, r.Files)
|
||||||
// assert.Equal(t, r.Glob, "*.testtmpl")
|
// assert.Equal(t, "*.testtmpl", r.Glob)
|
||||||
//
|
//
|
||||||
// router.LoadHTMLFiles("index.html.testtmpl", "login.html.testtmpl")
|
// router.LoadHTMLFiles("index.html.testtmpl", "login.html.testtmpl")
|
||||||
// r = router.HTMLRender.(render.HTMLDebug)
|
// r = router.HTMLRender.(render.HTMLDebug)
|
||||||
// assert.Empty(t, r.Glob)
|
// assert.Empty(t, r.Glob)
|
||||||
// assert.Equal(t, r.Files, []string{"index.html", "login.html"})
|
// assert.Equal(t, []string{"index.html", "login.html"}, r.Files)
|
||||||
// SetMode(TestMode)
|
// SetMode(TestMode)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func TestLoadHTMLFiles(t *testing.T) {
|
func TestLoadHTMLFiles(t *testing.T) {
|
||||||
td := setupHTMLFiles(t)
|
td := setupHTMLFiles(t, TestMode, false)
|
||||||
res, err := http.Get("http://127.0.0.1:8888/test")
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -138,9 +191,52 @@ func TestLoadHTMLFiles(t *testing.T) {
|
|||||||
td()
|
td()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLFiles2(t *testing.T) {
|
||||||
|
td := setupHTMLFiles(t, DebugMode, false)
|
||||||
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLFiles3(t *testing.T) {
|
||||||
|
td := setupHTMLFiles(t, ReleaseMode, false)
|
||||||
|
res, err := http.Get("http://127.0.0.1:8888/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadHTMLFilesUsingTLS(t *testing.T) {
|
||||||
|
td := setupHTMLFiles(t, TestMode, true)
|
||||||
|
// Use InsecureSkipVerify for avoiding `x509: certificate signed by unknown authority` error
|
||||||
|
tr := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
client := &http.Client{Transport: tr}
|
||||||
|
res, err := client.Get("https://127.0.0.1:9999/test")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, _ := ioutil.ReadAll(res.Body)
|
||||||
|
assert.Equal(t, "<h1>Hello world</h1>", string(resp[:]))
|
||||||
|
td()
|
||||||
|
}
|
||||||
|
|
||||||
func TestLoadHTMLFilesFuncMap(t *testing.T) {
|
func TestLoadHTMLFilesFuncMap(t *testing.T) {
|
||||||
time.Now()
|
time.Now()
|
||||||
td := setupHTMLFiles(t)
|
td := setupHTMLFiles(t, TestMode, false)
|
||||||
res, err := http.Get("http://127.0.0.1:8888/raw")
|
res, err := http.Get("http://127.0.0.1:8888/raw")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -152,10 +248,6 @@ func TestLoadHTMLFilesFuncMap(t *testing.T) {
|
|||||||
td()
|
td()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadHTMLReleaseMode(t *testing.T) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAddRoute(t *testing.T) {
|
func TestAddRoute(t *testing.T) {
|
||||||
router := New()
|
router := New()
|
||||||
router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})
|
router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})
|
||||||
|
2
vendor/github.com/gin-gonic/gin/githubapi_test.go
generated
vendored
2
vendor/github.com/gin-gonic/gin/githubapi_test.go
generated
vendored
@ -293,7 +293,7 @@ func githubConfigRouter(router *Engine) {
|
|||||||
for _, param := range c.Params {
|
for _, param := range c.Params {
|
||||||
output[param.Key] = param.Value
|
output[param.Key] = param.Value
|
||||||
}
|
}
|
||||||
c.JSON(200, output)
|
c.JSON(http.StatusOK, output)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
vendor/github.com/gin-gonic/gin/json/json.go
generated
vendored
Normal file
15
vendor/github.com/gin-gonic/gin/json/json.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2017 Bo-Yi Wu. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !jsoniter
|
||||||
|
|
||||||
|
package json
|
||||||
|
|
||||||
|
import "encoding/json"
|
||||||
|
|
||||||
|
var (
|
||||||
|
Marshal = json.Marshal
|
||||||
|
MarshalIndent = json.MarshalIndent
|
||||||
|
NewDecoder = json.NewDecoder
|
||||||
|
)
|
16
vendor/github.com/gin-gonic/gin/json/jsoniter.go
generated
vendored
Normal file
16
vendor/github.com/gin-gonic/gin/json/jsoniter.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2017 Bo-Yi Wu. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build jsoniter
|
||||||
|
|
||||||
|
package json
|
||||||
|
|
||||||
|
import "github.com/json-iterator/go"
|
||||||
|
|
||||||
|
var (
|
||||||
|
json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
|
Marshal = json.Marshal
|
||||||
|
MarshalIndent = json.MarshalIndent
|
||||||
|
NewDecoder = json.NewDecoder
|
||||||
|
)
|
28
vendor/github.com/gin-gonic/gin/logger.go
generated
vendored
28
vendor/github.com/gin-gonic/gin/logger.go
generated
vendored
@ -7,6 +7,7 @@ package gin
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -25,14 +26,17 @@ var (
|
|||||||
disableColor = false
|
disableColor = false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DisableConsoleColor disables color output in the console.
|
||||||
func DisableConsoleColor() {
|
func DisableConsoleColor() {
|
||||||
disableColor = true
|
disableColor = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrorLogger returns a handlerfunc for any error type.
|
||||||
func ErrorLogger() HandlerFunc {
|
func ErrorLogger() HandlerFunc {
|
||||||
return ErrorLoggerT(ErrorTypeAny)
|
return ErrorLoggerT(ErrorTypeAny)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrorLoggerT returns a handlerfunc for a given error type.
|
||||||
func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
||||||
return func(c *Context) {
|
return func(c *Context) {
|
||||||
c.Next()
|
c.Next()
|
||||||
@ -43,8 +47,8 @@ func ErrorLoggerT(typ ErrorType) HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter
|
// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter.
|
||||||
// By default gin.DefaultWriter = os.Stdout
|
// By default gin.DefaultWriter = os.Stdout.
|
||||||
func Logger() HandlerFunc {
|
func Logger() HandlerFunc {
|
||||||
return LoggerWithWriter(DefaultWriter)
|
return LoggerWithWriter(DefaultWriter)
|
||||||
}
|
}
|
||||||
@ -74,6 +78,7 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
|
|||||||
// Start timer
|
// Start timer
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
path := c.Request.URL.Path
|
path := c.Request.URL.Path
|
||||||
|
raw := c.Request.URL.RawQuery
|
||||||
|
|
||||||
// Process request
|
// Process request
|
||||||
c.Next()
|
c.Next()
|
||||||
@ -87,19 +92,24 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
|
|||||||
clientIP := c.ClientIP()
|
clientIP := c.ClientIP()
|
||||||
method := c.Request.Method
|
method := c.Request.Method
|
||||||
statusCode := c.Writer.Status()
|
statusCode := c.Writer.Status()
|
||||||
var statusColor, methodColor string
|
var statusColor, methodColor, resetColor string
|
||||||
if isTerm {
|
if isTerm {
|
||||||
statusColor = colorForStatus(statusCode)
|
statusColor = colorForStatus(statusCode)
|
||||||
methodColor = colorForMethod(method)
|
methodColor = colorForMethod(method)
|
||||||
|
resetColor = reset
|
||||||
}
|
}
|
||||||
comment := c.Errors.ByType(ErrorTypePrivate).String()
|
comment := c.Errors.ByType(ErrorTypePrivate).String()
|
||||||
|
|
||||||
fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %s %-7s %s\n%s",
|
if raw != "" {
|
||||||
|
path = path + "?" + raw
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
|
||||||
end.Format("2006/01/02 - 15:04:05"),
|
end.Format("2006/01/02 - 15:04:05"),
|
||||||
statusColor, statusCode, reset,
|
statusColor, statusCode, resetColor,
|
||||||
latency,
|
latency,
|
||||||
clientIP,
|
clientIP,
|
||||||
methodColor, method, reset,
|
methodColor, method, resetColor,
|
||||||
path,
|
path,
|
||||||
comment,
|
comment,
|
||||||
)
|
)
|
||||||
@ -109,11 +119,11 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
|
|||||||
|
|
||||||
func colorForStatus(code int) string {
|
func colorForStatus(code int) string {
|
||||||
switch {
|
switch {
|
||||||
case code >= 200 && code < 300:
|
case code >= http.StatusOK && code < http.StatusMultipleChoices:
|
||||||
return green
|
return green
|
||||||
case code >= 300 && code < 400:
|
case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
|
||||||
return white
|
return white
|
||||||
case code >= 400 && code < 500:
|
case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
|
||||||
return yellow
|
return yellow
|
||||||
default:
|
default:
|
||||||
return red
|
return red
|
||||||
|
38
vendor/github.com/gin-gonic/gin/logger_test.go
generated
vendored
38
vendor/github.com/gin-gonic/gin/logger_test.go
generated
vendored
@ -7,6 +7,7 @@ package gin
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -28,10 +29,11 @@ func TestLogger(t *testing.T) {
|
|||||||
router.HEAD("/example", func(c *Context) {})
|
router.HEAD("/example", func(c *Context) {})
|
||||||
router.OPTIONS("/example", func(c *Context) {})
|
router.OPTIONS("/example", func(c *Context) {})
|
||||||
|
|
||||||
performRequest(router, "GET", "/example")
|
performRequest(router, "GET", "/example?a=100")
|
||||||
assert.Contains(t, buffer.String(), "200")
|
assert.Contains(t, buffer.String(), "200")
|
||||||
assert.Contains(t, buffer.String(), "GET")
|
assert.Contains(t, buffer.String(), "GET")
|
||||||
assert.Contains(t, buffer.String(), "/example")
|
assert.Contains(t, buffer.String(), "/example")
|
||||||
|
assert.Contains(t, buffer.String(), "a=100")
|
||||||
|
|
||||||
// I wrote these first (extending the above) but then realized they are more
|
// I wrote these first (extending the above) but then realized they are more
|
||||||
// like integration tests because they test the whole logging process rather
|
// like integration tests because they test the whole logging process rather
|
||||||
@ -81,21 +83,21 @@ func TestLogger(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestColorForMethod(t *testing.T) {
|
func TestColorForMethod(t *testing.T) {
|
||||||
assert.Equal(t, colorForMethod("GET"), string([]byte{27, 91, 57, 55, 59, 52, 52, 109}), "get should be blue")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 52, 109}), colorForMethod("GET"), "get should be blue")
|
||||||
assert.Equal(t, colorForMethod("POST"), string([]byte{27, 91, 57, 55, 59, 52, 54, 109}), "post should be cyan")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 54, 109}), colorForMethod("POST"), "post should be cyan")
|
||||||
assert.Equal(t, colorForMethod("PUT"), string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), "put should be yellow")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), colorForMethod("PUT"), "put should be yellow")
|
||||||
assert.Equal(t, colorForMethod("DELETE"), string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), "delete should be red")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), colorForMethod("DELETE"), "delete should be red")
|
||||||
assert.Equal(t, colorForMethod("PATCH"), string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), "patch should be green")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), colorForMethod("PATCH"), "patch should be green")
|
||||||
assert.Equal(t, colorForMethod("HEAD"), string([]byte{27, 91, 57, 55, 59, 52, 53, 109}), "head should be magenta")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 53, 109}), colorForMethod("HEAD"), "head should be magenta")
|
||||||
assert.Equal(t, colorForMethod("OPTIONS"), string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), "options should be white")
|
assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), colorForMethod("OPTIONS"), "options should be white")
|
||||||
assert.Equal(t, colorForMethod("TRACE"), string([]byte{27, 91, 48, 109}), "trace is not defined and should be the reset color")
|
assert.Equal(t, string([]byte{27, 91, 48, 109}), colorForMethod("TRACE"), "trace is not defined and should be the reset color")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestColorForStatus(t *testing.T) {
|
func TestColorForStatus(t *testing.T) {
|
||||||
assert.Equal(t, colorForStatus(200), string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), "2xx should be green")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 50, 109}), colorForStatus(http.StatusOK), "2xx should be green")
|
||||||
assert.Equal(t, colorForStatus(301), string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), "3xx should be white")
|
assert.Equal(t, string([]byte{27, 91, 57, 48, 59, 52, 55, 109}), colorForStatus(http.StatusMovedPermanently), "3xx should be white")
|
||||||
assert.Equal(t, colorForStatus(404), string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), "4xx should be yellow")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 51, 109}), colorForStatus(http.StatusNotFound), "4xx should be yellow")
|
||||||
assert.Equal(t, colorForStatus(2), string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), "other things should be red")
|
assert.Equal(t, string([]byte{27, 91, 57, 55, 59, 52, 49, 109}), colorForStatus(2), "other things should be red")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestErrorLogger(t *testing.T) {
|
func TestErrorLogger(t *testing.T) {
|
||||||
@ -105,23 +107,23 @@ func TestErrorLogger(t *testing.T) {
|
|||||||
c.Error(errors.New("this is an error"))
|
c.Error(errors.New("this is an error"))
|
||||||
})
|
})
|
||||||
router.GET("/abort", func(c *Context) {
|
router.GET("/abort", func(c *Context) {
|
||||||
c.AbortWithError(401, errors.New("no authorized"))
|
c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized"))
|
||||||
})
|
})
|
||||||
router.GET("/print", func(c *Context) {
|
router.GET("/print", func(c *Context) {
|
||||||
c.Error(errors.New("this is an error"))
|
c.Error(errors.New("this is an error"))
|
||||||
c.String(500, "hola!")
|
c.String(http.StatusInternalServerError, "hola!")
|
||||||
})
|
})
|
||||||
|
|
||||||
w := performRequest(router, "GET", "/error")
|
w := performRequest(router, "GET", "/error")
|
||||||
assert.Equal(t, 200, w.Code)
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
assert.Equal(t, "{\"error\":\"this is an error\"}", w.Body.String())
|
assert.Equal(t, "{\"error\":\"this is an error\"}", w.Body.String())
|
||||||
|
|
||||||
w = performRequest(router, "GET", "/abort")
|
w = performRequest(router, "GET", "/abort")
|
||||||
assert.Equal(t, 401, w.Code)
|
assert.Equal(t, http.StatusUnauthorized, w.Code)
|
||||||
assert.Equal(t, "{\"error\":\"no authorized\"}", w.Body.String())
|
assert.Equal(t, "{\"error\":\"no authorized\"}", w.Body.String())
|
||||||
|
|
||||||
w = performRequest(router, "GET", "/print")
|
w = performRequest(router, "GET", "/print")
|
||||||
assert.Equal(t, 500, w.Code)
|
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||||
assert.Equal(t, "hola!{\"error\":\"this is an error\"}", w.Body.String())
|
assert.Equal(t, "hola!{\"error\":\"this is an error\"}", w.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
vendor/github.com/gin-gonic/gin/logo.jpg
generated
vendored
BIN
vendor/github.com/gin-gonic/gin/logo.jpg
generated
vendored
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
47
vendor/github.com/gin-gonic/gin/middleware_test.go
generated
vendored
47
vendor/github.com/gin-gonic/gin/middleware_test.go
generated
vendored
@ -6,6 +6,7 @@ package gin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -37,8 +38,8 @@ func TestMiddlewareGeneralCase(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 200)
|
assert.Equal(t, http.StatusOK, w.Code)
|
||||||
assert.Equal(t, signature, "ACDB")
|
assert.Equal(t, "ACDB", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareNoRoute(t *testing.T) {
|
func TestMiddlewareNoRoute(t *testing.T) {
|
||||||
@ -73,8 +74,8 @@ func TestMiddlewareNoRoute(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 404)
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
assert.Equal(t, signature, "ACEGHFDB")
|
assert.Equal(t, "ACEGHFDB", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareNoMethodEnabled(t *testing.T) {
|
func TestMiddlewareNoMethodEnabled(t *testing.T) {
|
||||||
@ -110,8 +111,8 @@ func TestMiddlewareNoMethodEnabled(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 405)
|
assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
|
||||||
assert.Equal(t, signature, "ACEGHFDB")
|
assert.Equal(t, "ACEGHFDB", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareNoMethodDisabled(t *testing.T) {
|
func TestMiddlewareNoMethodDisabled(t *testing.T) {
|
||||||
@ -147,8 +148,8 @@ func TestMiddlewareNoMethodDisabled(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 404)
|
assert.Equal(t, http.StatusNotFound, w.Code)
|
||||||
assert.Equal(t, signature, "AC X DB")
|
assert.Equal(t, "AC X DB", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareAbort(t *testing.T) {
|
func TestMiddlewareAbort(t *testing.T) {
|
||||||
@ -159,7 +160,7 @@ func TestMiddlewareAbort(t *testing.T) {
|
|||||||
})
|
})
|
||||||
router.Use(func(c *Context) {
|
router.Use(func(c *Context) {
|
||||||
signature += "C"
|
signature += "C"
|
||||||
c.AbortWithStatus(401)
|
c.AbortWithStatus(http.StatusUnauthorized)
|
||||||
c.Next()
|
c.Next()
|
||||||
signature += "D"
|
signature += "D"
|
||||||
})
|
})
|
||||||
@ -173,8 +174,8 @@ func TestMiddlewareAbort(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 401)
|
assert.Equal(t, http.StatusUnauthorized, w.Code)
|
||||||
assert.Equal(t, signature, "ACD")
|
assert.Equal(t, "ACD", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) {
|
func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) {
|
||||||
@ -183,7 +184,7 @@ func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) {
|
|||||||
router.Use(func(c *Context) {
|
router.Use(func(c *Context) {
|
||||||
signature += "A"
|
signature += "A"
|
||||||
c.Next()
|
c.Next()
|
||||||
c.AbortWithStatus(410)
|
c.AbortWithStatus(http.StatusGone)
|
||||||
signature += "B"
|
signature += "B"
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -195,8 +196,8 @@ func TestMiddlewareAbortHandlersChainAndNext(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 410)
|
assert.Equal(t, http.StatusGone, w.Code)
|
||||||
assert.Equal(t, signature, "ACB")
|
assert.Equal(t, "ACB", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as
|
// TestFailHandlersChain - ensure that Fail interrupt used middleware in fifo order as
|
||||||
@ -207,7 +208,7 @@ func TestMiddlewareFailHandlersChain(t *testing.T) {
|
|||||||
router := New()
|
router := New()
|
||||||
router.Use(func(context *Context) {
|
router.Use(func(context *Context) {
|
||||||
signature += "A"
|
signature += "A"
|
||||||
context.AbortWithError(500, errors.New("foo"))
|
context.AbortWithError(http.StatusInternalServerError, errors.New("foo"))
|
||||||
})
|
})
|
||||||
router.Use(func(context *Context) {
|
router.Use(func(context *Context) {
|
||||||
signature += "B"
|
signature += "B"
|
||||||
@ -218,25 +219,25 @@ func TestMiddlewareFailHandlersChain(t *testing.T) {
|
|||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 500)
|
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||||
assert.Equal(t, signature, "A")
|
assert.Equal(t, "A", signature)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMiddlewareWrite(t *testing.T) {
|
func TestMiddlewareWrite(t *testing.T) {
|
||||||
router := New()
|
router := New()
|
||||||
router.Use(func(c *Context) {
|
router.Use(func(c *Context) {
|
||||||
c.String(400, "hola\n")
|
c.String(http.StatusBadRequest, "hola\n")
|
||||||
})
|
})
|
||||||
router.Use(func(c *Context) {
|
router.Use(func(c *Context) {
|
||||||
c.XML(400, H{"foo": "bar"})
|
c.XML(http.StatusBadRequest, H{"foo": "bar"})
|
||||||
})
|
})
|
||||||
router.Use(func(c *Context) {
|
router.Use(func(c *Context) {
|
||||||
c.JSON(400, H{"foo": "bar"})
|
c.JSON(http.StatusBadRequest, H{"foo": "bar"})
|
||||||
})
|
})
|
||||||
router.GET("/", func(c *Context) {
|
router.GET("/", func(c *Context) {
|
||||||
c.JSON(400, H{"foo": "bar"})
|
c.JSON(http.StatusBadRequest, H{"foo": "bar"})
|
||||||
}, func(c *Context) {
|
}, func(c *Context) {
|
||||||
c.Render(400, sse.Event{
|
c.Render(http.StatusBadRequest, sse.Event{
|
||||||
Event: "test",
|
Event: "test",
|
||||||
Data: "message",
|
Data: "message",
|
||||||
})
|
})
|
||||||
@ -244,6 +245,6 @@ func TestMiddlewareWrite(t *testing.T) {
|
|||||||
|
|
||||||
w := performRequest(router, "GET", "/")
|
w := performRequest(router, "GET", "/")
|
||||||
|
|
||||||
assert.Equal(t, 400, w.Code)
|
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||||
assert.Equal(t, strings.Replace("hola\n<map><foo>bar</foo></map>{\"foo\":\"bar\"}{\"foo\":\"bar\"}event:test\ndata:message\n\n", " ", "", -1), strings.Replace(w.Body.String(), " ", "", -1))
|
assert.Equal(t, strings.Replace("hola\n<map><foo>bar</foo></map>{\"foo\":\"bar\"}{\"foo\":\"bar\"}event:test\ndata:message\n\n", " ", "", -1), strings.Replace(w.Body.String(), " ", "", -1))
|
||||||
}
|
}
|
||||||
|
21
vendor/github.com/gin-gonic/gin/mode.go
generated
vendored
21
vendor/github.com/gin-gonic/gin/mode.go
generated
vendored
@ -14,9 +14,9 @@ import (
|
|||||||
const ENV_GIN_MODE = "GIN_MODE"
|
const ENV_GIN_MODE = "GIN_MODE"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DebugMode string = "debug"
|
DebugMode = "debug"
|
||||||
ReleaseMode string = "release"
|
ReleaseMode = "release"
|
||||||
TestMode string = "test"
|
TestMode = "test"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
debugCode = iota
|
debugCode = iota
|
||||||
@ -39,16 +39,12 @@ var modeName = DebugMode
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
mode := os.Getenv(ENV_GIN_MODE)
|
mode := os.Getenv(ENV_GIN_MODE)
|
||||||
if len(mode) == 0 {
|
SetMode(mode)
|
||||||
SetMode(DebugMode)
|
|
||||||
} else {
|
|
||||||
SetMode(mode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetMode(value string) {
|
func SetMode(value string) {
|
||||||
switch value {
|
switch value {
|
||||||
case DebugMode:
|
case DebugMode, "":
|
||||||
ginMode = debugCode
|
ginMode = debugCode
|
||||||
case ReleaseMode:
|
case ReleaseMode:
|
||||||
ginMode = releaseCode
|
ginMode = releaseCode
|
||||||
@ -57,6 +53,9 @@ func SetMode(value string) {
|
|||||||
default:
|
default:
|
||||||
panic("gin mode unknown: " + value)
|
panic("gin mode unknown: " + value)
|
||||||
}
|
}
|
||||||
|
if value == "" {
|
||||||
|
value = DebugMode
|
||||||
|
}
|
||||||
modeName = value
|
modeName = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +63,10 @@ func DisableBindValidation() {
|
|||||||
binding.Validator = nil
|
binding.Validator = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EnableJsonDecoderUseNumber() {
|
||||||
|
binding.EnableDecoderUseNumber = true
|
||||||
|
}
|
||||||
|
|
||||||
func Mode() string {
|
func Mode() string {
|
||||||
return modeName
|
return modeName
|
||||||
}
|
}
|
||||||
|
30
vendor/github.com/gin-gonic/gin/mode_test.go
generated
vendored
30
vendor/github.com/gin-gonic/gin/mode_test.go
generated
vendored
@ -5,27 +5,43 @@
|
|||||||
package gin
|
package gin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
SetMode(TestMode)
|
os.Setenv(ENV_GIN_MODE, TestMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetMode(t *testing.T) {
|
func TestSetMode(t *testing.T) {
|
||||||
|
assert.Equal(t, testCode, ginMode)
|
||||||
|
assert.Equal(t, TestMode, Mode())
|
||||||
|
os.Unsetenv(ENV_GIN_MODE)
|
||||||
|
|
||||||
|
SetMode("")
|
||||||
|
assert.Equal(t, debugCode, ginMode)
|
||||||
|
assert.Equal(t, DebugMode, Mode())
|
||||||
|
|
||||||
SetMode(DebugMode)
|
SetMode(DebugMode)
|
||||||
assert.Equal(t, ginMode, debugCode)
|
assert.Equal(t, debugCode, ginMode)
|
||||||
assert.Equal(t, Mode(), DebugMode)
|
assert.Equal(t, DebugMode, Mode())
|
||||||
|
|
||||||
SetMode(ReleaseMode)
|
SetMode(ReleaseMode)
|
||||||
assert.Equal(t, ginMode, releaseCode)
|
assert.Equal(t, releaseCode, ginMode)
|
||||||
assert.Equal(t, Mode(), ReleaseMode)
|
assert.Equal(t, ReleaseMode, Mode())
|
||||||
|
|
||||||
SetMode(TestMode)
|
SetMode(TestMode)
|
||||||
assert.Equal(t, ginMode, testCode)
|
assert.Equal(t, testCode, ginMode)
|
||||||
assert.Equal(t, Mode(), TestMode)
|
assert.Equal(t, TestMode, Mode())
|
||||||
|
|
||||||
assert.Panics(t, func() { SetMode("unknown") })
|
assert.Panics(t, func() { SetMode("unknown") })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEnableJsonDecoderUseNumber(t *testing.T) {
|
||||||
|
assert.False(t, binding.EnableDecoderUseNumber)
|
||||||
|
EnableJsonDecoderUseNumber()
|
||||||
|
assert.True(t, binding.EnableDecoderUseNumber)
|
||||||
|
}
|
||||||
|
12
vendor/github.com/gin-gonic/gin/path.go
generated
vendored
12
vendor/github.com/gin-gonic/gin/path.go
generated
vendored
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package gin
|
package gin
|
||||||
|
|
||||||
// CleanPath is the URL version of path.Clean, it returns a canonical URL path
|
// cleanPath is the URL version of path.Clean, it returns a canonical URL path
|
||||||
// for p, eliminating . and .. elements.
|
// for p, eliminating . and .. elements.
|
||||||
//
|
//
|
||||||
// The following rules are applied iteratively until no further processing can
|
// The following rules are applied iteratively until no further processing can
|
||||||
@ -17,7 +17,7 @@ package gin
|
|||||||
// 4. Eliminate .. elements that begin a rooted path:
|
// 4. Eliminate .. elements that begin a rooted path:
|
||||||
// that is, replace "/.." by "/" at the beginning of a path.
|
// that is, replace "/.." by "/" at the beginning of a path.
|
||||||
//
|
//
|
||||||
// If the result of this process is an empty string, "/" is returned
|
// If the result of this process is an empty string, "/" is returned.
|
||||||
func cleanPath(p string) string {
|
func cleanPath(p string) string {
|
||||||
// Turn empty string into "/"
|
// Turn empty string into "/"
|
||||||
if p == "" {
|
if p == "" {
|
||||||
@ -41,7 +41,7 @@ func cleanPath(p string) string {
|
|||||||
buf[0] = '/'
|
buf[0] = '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
trailing := n > 2 && p[n-1] == '/'
|
trailing := n > 1 && p[n-1] == '/'
|
||||||
|
|
||||||
// A bit more clunky without a 'lazybuf' like the path package, but the loop
|
// A bit more clunky without a 'lazybuf' like the path package, but the loop
|
||||||
// gets completely inlined (bufApp). So in contrast to the path package this
|
// gets completely inlined (bufApp). So in contrast to the path package this
|
||||||
@ -59,11 +59,11 @@ func cleanPath(p string) string {
|
|||||||
|
|
||||||
case p[r] == '.' && p[r+1] == '/':
|
case p[r] == '.' && p[r+1] == '/':
|
||||||
// . element
|
// . element
|
||||||
r++
|
r += 2
|
||||||
|
|
||||||
case p[r] == '.' && p[r+1] == '.' && (r+2 == n || p[r+2] == '/'):
|
case p[r] == '.' && p[r+1] == '.' && (r+2 == n || p[r+2] == '/'):
|
||||||
// .. element: remove to last /
|
// .. element: remove to last /
|
||||||
r += 2
|
r += 3
|
||||||
|
|
||||||
if w > 1 {
|
if w > 1 {
|
||||||
// can backtrack
|
// can backtrack
|
||||||
@ -109,7 +109,7 @@ func cleanPath(p string) string {
|
|||||||
return string(buf[:w])
|
return string(buf[:w])
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper to lazily create a buffer if necessary
|
// internal helper to lazily create a buffer if necessary.
|
||||||
func bufApp(buf *[]byte, s string, w int, c byte) {
|
func bufApp(buf *[]byte, s string, w int, c byte) {
|
||||||
if *buf == nil {
|
if *buf == nil {
|
||||||
if s[w] == c {
|
if s[w] == c {
|
||||||
|
5
vendor/github.com/gin-gonic/gin/path_test.go
generated
vendored
5
vendor/github.com/gin-gonic/gin/path_test.go
generated
vendored
@ -24,6 +24,7 @@ var cleanTests = []struct {
|
|||||||
|
|
||||||
// missing root
|
// missing root
|
||||||
{"", "/"},
|
{"", "/"},
|
||||||
|
{"a/", "/a/"},
|
||||||
{"abc", "/abc"},
|
{"abc", "/abc"},
|
||||||
{"abc/def", "/abc/def"},
|
{"abc/def", "/abc/def"},
|
||||||
{"a/b/c", "/a/b/c"},
|
{"a/b/c", "/a/b/c"},
|
||||||
@ -67,8 +68,8 @@ var cleanTests = []struct {
|
|||||||
|
|
||||||
func TestPathClean(t *testing.T) {
|
func TestPathClean(t *testing.T) {
|
||||||
for _, test := range cleanTests {
|
for _, test := range cleanTests {
|
||||||
assert.Equal(t, cleanPath(test.path), test.result)
|
assert.Equal(t, test.result, cleanPath(test.path))
|
||||||
assert.Equal(t, cleanPath(test.result), test.result)
|
assert.Equal(t, test.result, cleanPath(test.result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
vendor/github.com/gin-gonic/gin/recovery.go
generated
vendored
14
vendor/github.com/gin-gonic/gin/recovery.go
generated
vendored
@ -10,8 +10,10 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -26,6 +28,7 @@ func Recovery() HandlerFunc {
|
|||||||
return RecoveryWithWriter(DefaultErrorWriter)
|
return RecoveryWithWriter(DefaultErrorWriter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
|
||||||
func RecoveryWithWriter(out io.Writer) HandlerFunc {
|
func RecoveryWithWriter(out io.Writer) HandlerFunc {
|
||||||
var logger *log.Logger
|
var logger *log.Logger
|
||||||
if out != nil {
|
if out != nil {
|
||||||
@ -37,16 +40,16 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
|
|||||||
if logger != nil {
|
if logger != nil {
|
||||||
stack := stack(3)
|
stack := stack(3)
|
||||||
httprequest, _ := httputil.DumpRequest(c.Request, false)
|
httprequest, _ := httputil.DumpRequest(c.Request, false)
|
||||||
logger.Printf("[Recovery] panic recovered:\n%s\n%s\n%s%s", string(httprequest), err, stack, reset)
|
logger.Printf("[Recovery] %s panic recovered:\n%s\n%s\n%s%s", timeFormat(time.Now()), string(httprequest), err, stack, reset)
|
||||||
}
|
}
|
||||||
c.AbortWithStatus(500)
|
c.AbortWithStatus(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stack returns a nicely formated stack frame, skipping skip frames
|
// stack returns a nicely formatted stack frame, skipping skip frames.
|
||||||
func stack(skip int) []byte {
|
func stack(skip int) []byte {
|
||||||
buf := new(bytes.Buffer) // the returned data
|
buf := new(bytes.Buffer) // the returned data
|
||||||
// As we loop, we open files and read them. These variables record the currently
|
// As we loop, we open files and read them. These variables record the currently
|
||||||
@ -106,3 +109,8 @@ func function(pc uintptr) []byte {
|
|||||||
name = bytes.Replace(name, centerDot, dot, -1)
|
name = bytes.Replace(name, centerDot, dot, -1)
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func timeFormat(t time.Time) string {
|
||||||
|
var timeString = t.Format("2006/01/02 - 15:04:05")
|
||||||
|
return timeString
|
||||||
|
}
|
||||||
|
27
vendor/github.com/gin-gonic/gin/recovery_test.go
generated
vendored
27
vendor/github.com/gin-gonic/gin/recovery_test.go
generated
vendored
@ -6,6 +6,7 @@ package gin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -22,7 +23,7 @@ func TestPanicInHandler(t *testing.T) {
|
|||||||
// RUN
|
// RUN
|
||||||
w := performRequest(router, "GET", "/recovery")
|
w := performRequest(router, "GET", "/recovery")
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 500)
|
assert.Equal(t, http.StatusInternalServerError, w.Code)
|
||||||
assert.Contains(t, buffer.String(), "GET /recovery")
|
assert.Contains(t, buffer.String(), "GET /recovery")
|
||||||
assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem")
|
assert.Contains(t, buffer.String(), "Oupps, Houston, we have a problem")
|
||||||
assert.Contains(t, buffer.String(), "TestPanicInHandler")
|
assert.Contains(t, buffer.String(), "TestPanicInHandler")
|
||||||
@ -33,11 +34,31 @@ func TestPanicWithAbort(t *testing.T) {
|
|||||||
router := New()
|
router := New()
|
||||||
router.Use(RecoveryWithWriter(nil))
|
router.Use(RecoveryWithWriter(nil))
|
||||||
router.GET("/recovery", func(c *Context) {
|
router.GET("/recovery", func(c *Context) {
|
||||||
c.AbortWithStatus(400)
|
c.AbortWithStatus(http.StatusBadRequest)
|
||||||
panic("Oupps, Houston, we have a problem")
|
panic("Oupps, Houston, we have a problem")
|
||||||
})
|
})
|
||||||
// RUN
|
// RUN
|
||||||
w := performRequest(router, "GET", "/recovery")
|
w := performRequest(router, "GET", "/recovery")
|
||||||
// TEST
|
// TEST
|
||||||
assert.Equal(t, w.Code, 400)
|
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSource(t *testing.T) {
|
||||||
|
bs := source(nil, 0)
|
||||||
|
assert.Equal(t, []byte("???"), bs)
|
||||||
|
|
||||||
|
in := [][]byte{
|
||||||
|
[]byte("Hello world."),
|
||||||
|
[]byte("Hi, gin.."),
|
||||||
|
}
|
||||||
|
bs = source(in, 10)
|
||||||
|
assert.Equal(t, []byte("???"), bs)
|
||||||
|
|
||||||
|
bs = source(in, 1)
|
||||||
|
assert.Equal(t, []byte("Hello world."), bs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFunction(t *testing.T) {
|
||||||
|
bs := function(1)
|
||||||
|
assert.Equal(t, []byte("???"), bs)
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/gin-gonic/gin/render/data.go
generated
vendored
2
vendor/github.com/gin-gonic/gin/render/data.go
generated
vendored
@ -11,7 +11,7 @@ type Data struct {
|
|||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render (Data) writes data with custom ContentType
|
// Render (Data) writes data with custom ContentType.
|
||||||
func (r Data) Render(w http.ResponseWriter) (err error) {
|
func (r Data) Render(w http.ResponseWriter) (err error) {
|
||||||
r.WriteContentType(w)
|
r.WriteContentType(w)
|
||||||
_, err = w.Write(r.Data)
|
_, err = w.Write(r.Data)
|
||||||
|
50
vendor/github.com/gin-gonic/gin/render/html.go
generated
vendored
50
vendor/github.com/gin-gonic/gin/render/html.go
generated
vendored
@ -9,34 +9,32 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type Delims struct {
|
||||||
Delims struct {
|
Left string
|
||||||
Left string
|
Right string
|
||||||
Right string
|
}
|
||||||
}
|
|
||||||
|
|
||||||
HTMLRender interface {
|
type HTMLRender interface {
|
||||||
Instance(string, interface{}) Render
|
Instance(string, interface{}) Render
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLProduction struct {
|
type HTMLProduction struct {
|
||||||
Template *template.Template
|
Template *template.Template
|
||||||
Delims Delims
|
Delims Delims
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLDebug struct {
|
type HTMLDebug struct {
|
||||||
Files []string
|
Files []string
|
||||||
Glob string
|
Glob string
|
||||||
Delims Delims
|
Delims Delims
|
||||||
FuncMap template.FuncMap
|
FuncMap template.FuncMap
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML struct {
|
type HTML struct {
|
||||||
Template *template.Template
|
Template *template.Template
|
||||||
Name string
|
Name string
|
||||||
Data interface{}
|
Data interface{}
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
var htmlContentType = []string{"text/html; charset=utf-8"}
|
var htmlContentType = []string{"text/html; charset=utf-8"}
|
||||||
|
|
||||||
@ -62,7 +60,7 @@ func (r HTMLDebug) loadTemplate() *template.Template {
|
|||||||
if len(r.Files) > 0 {
|
if len(r.Files) > 0 {
|
||||||
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...))
|
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...))
|
||||||
}
|
}
|
||||||
if len(r.Glob) > 0 {
|
if r.Glob != "" {
|
||||||
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob))
|
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob))
|
||||||
}
|
}
|
||||||
panic("the HTML debug render was created without files or glob pattern")
|
panic("the HTML debug render was created without files or glob pattern")
|
||||||
@ -71,7 +69,7 @@ func (r HTMLDebug) loadTemplate() *template.Template {
|
|||||||
func (r HTML) Render(w http.ResponseWriter) error {
|
func (r HTML) Render(w http.ResponseWriter) error {
|
||||||
r.WriteContentType(w)
|
r.WriteContentType(w)
|
||||||
|
|
||||||
if len(r.Name) == 0 {
|
if r.Name == "" {
|
||||||
return r.Template.Execute(w, r.Data)
|
return r.Template.Execute(w, r.Data)
|
||||||
}
|
}
|
||||||
return r.Template.ExecuteTemplate(w, r.Name, r.Data)
|
return r.Template.ExecuteTemplate(w, r.Name, r.Data)
|
||||||
|
107
vendor/github.com/gin-gonic/gin/render/json.go
generated
vendored
Normal file → Executable file
107
vendor/github.com/gin-gonic/gin/render/json.go
generated
vendored
Normal file → Executable file
@ -5,21 +5,41 @@
|
|||||||
package render
|
package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type JSON struct {
|
||||||
JSON struct {
|
Data interface{}
|
||||||
Data interface{}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
IndentedJSON struct {
|
type IndentedJSON struct {
|
||||||
Data interface{}
|
Data interface{}
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
type SecureJSON struct {
|
||||||
|
Prefix string
|
||||||
|
Data interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonpJSON struct {
|
||||||
|
Callback string
|
||||||
|
Data interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type AsciiJSON struct {
|
||||||
|
Data interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SecureJSONPrefix string
|
||||||
|
|
||||||
var jsonContentType = []string{"application/json; charset=utf-8"}
|
var jsonContentType = []string{"application/json; charset=utf-8"}
|
||||||
|
var jsonpContentType = []string{"application/javascript; charset=utf-8"}
|
||||||
|
var jsonAsciiContentType = []string{"application/json"}
|
||||||
|
|
||||||
func (r JSON) Render(w http.ResponseWriter) (err error) {
|
func (r JSON) Render(w http.ResponseWriter) (err error) {
|
||||||
if err = WriteJSON(w, r.Data); err != nil {
|
if err = WriteJSON(w, r.Data); err != nil {
|
||||||
@ -55,3 +75,72 @@ func (r IndentedJSON) Render(w http.ResponseWriter) error {
|
|||||||
func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {
|
func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {
|
||||||
writeContentType(w, jsonContentType)
|
writeContentType(w, jsonContentType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r SecureJSON) Render(w http.ResponseWriter) error {
|
||||||
|
r.WriteContentType(w)
|
||||||
|
jsonBytes, err := json.Marshal(r.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// if the jsonBytes is array values
|
||||||
|
if bytes.HasPrefix(jsonBytes, []byte("[")) && bytes.HasSuffix(jsonBytes, []byte("]")) {
|
||||||
|
w.Write([]byte(r.Prefix))
|
||||||
|
}
|
||||||
|
w.Write(jsonBytes)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r SecureJSON) WriteContentType(w http.ResponseWriter) {
|
||||||
|
writeContentType(w, jsonContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
|
||||||
|
r.WriteContentType(w)
|
||||||
|
ret, err := json.Marshal(r.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Callback == "" {
|
||||||
|
w.Write(ret)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
callback := template.JSEscapeString(r.Callback)
|
||||||
|
w.Write([]byte(callback))
|
||||||
|
w.Write([]byte("("))
|
||||||
|
w.Write(ret)
|
||||||
|
w.Write([]byte(")"))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
|
||||||
|
writeContentType(w, jsonpContentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
|
||||||
|
r.WriteContentType(w)
|
||||||
|
ret, err := json.Marshal(r.Data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
for _, r := range string(ret) {
|
||||||
|
cvt := ""
|
||||||
|
if r < 128 {
|
||||||
|
cvt = string(r)
|
||||||
|
} else {
|
||||||
|
cvt = fmt.Sprintf("\\u%04x", int64(r))
|
||||||
|
}
|
||||||
|
buffer.WriteString(cvt)
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(buffer.Bytes())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {
|
||||||
|
writeContentType(w, jsonAsciiContentType)
|
||||||
|
}
|
||||||
|
36
vendor/github.com/gin-gonic/gin/render/reader.go
generated
vendored
Normal file
36
vendor/github.com/gin-gonic/gin/render/reader.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package render
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Reader struct {
|
||||||
|
ContentType string
|
||||||
|
ContentLength int64
|
||||||
|
Reader io.Reader
|
||||||
|
Headers map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render (Reader) writes data with custom ContentType and headers.
|
||||||
|
func (r Reader) Render(w http.ResponseWriter) (err error) {
|
||||||
|
r.WriteContentType(w)
|
||||||
|
r.Headers["Content-Length"] = strconv.FormatInt(r.ContentLength, 10)
|
||||||
|
r.writeHeaders(w, r.Headers)
|
||||||
|
_, err = io.Copy(w, r.Reader)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Reader) WriteContentType(w http.ResponseWriter) {
|
||||||
|
writeContentType(w, []string{r.ContentType})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Reader) writeHeaders(w http.ResponseWriter, headers map[string]string) {
|
||||||
|
header := w.Header()
|
||||||
|
for k, v := range headers {
|
||||||
|
if val := header[k]; len(val) == 0 {
|
||||||
|
header[k] = []string{v}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user