mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
Update gin.go
finish TODO
This commit is contained in:
parent
bb8194b526
commit
2396d620c6
55
gin.go
55
gin.go
@ -1,4 +1,34 @@
|
|||||||
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
|
Skip to content
|
||||||
|
Search or jump to…
|
||||||
|
Pull requests
|
||||||
|
Issues
|
||||||
|
Marketplace
|
||||||
|
Explore
|
||||||
|
|
||||||
|
@359859461
|
||||||
|
gin-gonic
|
||||||
|
/
|
||||||
|
gin
|
||||||
|
Public
|
||||||
|
Code
|
||||||
|
Issues
|
||||||
|
427
|
||||||
|
Pull requests
|
||||||
|
118
|
||||||
|
Actions
|
||||||
|
Security
|
||||||
|
Insights
|
||||||
|
gin/gin.go /
|
||||||
|
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
|
||||||
|
@359859461
|
||||||
|
359859461 Update gin.go
|
||||||
|
Latest commit ee7c6d0 on 7 May
|
||||||
|
History
|
||||||
|
59 contributors
|
||||||
|
@manucorporat@thinkerou@javierprovecho@appleboy@jincheng9@Bisstocuz@vkd@easonlin404@pinscript@ngerakines@donileo@chad-russell
|
||||||
|
777 lines (670 sloc) 23.7 KB
|
||||||
|
|
||||||
|
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT style
|
// Use of this source code is governed by a MIT style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -147,9 +177,6 @@ type Engine struct {
|
|||||||
// UseH2C enable h2c support.
|
// UseH2C enable h2c support.
|
||||||
UseH2C bool
|
UseH2C bool
|
||||||
|
|
||||||
// ContextWithFallback enable fallback Context.Deadline(), Context.Done(), Context.Err() and Context.Value() when Context.Request.Context() is not nil.
|
|
||||||
ContextWithFallback bool
|
|
||||||
|
|
||||||
delims render.Delims
|
delims render.Delims
|
||||||
secureJSONPrefix string
|
secureJSONPrefix string
|
||||||
HTMLRender render.HTMLRender
|
HTMLRender render.HTMLRender
|
||||||
@ -198,7 +225,7 @@ func New() *Engine {
|
|||||||
trees: make(methodTrees, 0, 9),
|
trees: make(methodTrees, 0, 9),
|
||||||
delims: render.Delims{Left: "{{", Right: "}}"},
|
delims: render.Delims{Left: "{{", Right: "}}"},
|
||||||
secureJSONPrefix: "while(1);",
|
secureJSONPrefix: "while(1);",
|
||||||
trustedProxies: []string{"0.0.0.0/0", "::/0"},
|
trustedProxies: []string{"0.0.0.0/0"},
|
||||||
trustedCIDRs: defaultTrustedCIDRs,
|
trustedCIDRs: defaultTrustedCIDRs,
|
||||||
}
|
}
|
||||||
engine.RouterGroup.engine = engine
|
engine.RouterGroup.engine = engine
|
||||||
@ -210,7 +237,6 @@ 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 {
|
||||||
println("hello hsy")
|
|
||||||
debugPrintWARNINGDefault()
|
debugPrintWARNINGDefault()
|
||||||
engine := New()
|
engine := New()
|
||||||
engine.Use(Logger(), Recovery())
|
engine.Use(Logger(), Recovery())
|
||||||
@ -341,6 +367,7 @@ func (engine *Engine) addRoute(method, path string, handlers HandlersChain) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (engine *Engine) delRoute(method, path string) {
|
func (engine *Engine) delRoute(method, path string) {
|
||||||
assert1(path[0] == '/', "path must begin with '/'")
|
assert1(path[0] == '/', "path must begin with '/'")
|
||||||
assert1(method != "", "HTTP method can not be empty")
|
assert1(method != "", "HTTP method can not be empty")
|
||||||
@ -400,8 +427,8 @@ func (n *node) delChildNode(target *node){
|
|||||||
default:
|
default:
|
||||||
target.handlers = nil
|
target.handlers = nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Routes returns a slice of registered routes, including some useful information, such as:
|
// Routes returns a slice of registered routes, including some useful information, such as:
|
||||||
// the http method, path and the handler name.
|
// the http method, path and the handler name.
|
||||||
@ -765,3 +792,17 @@ func redirectRequest(c *Context) {
|
|||||||
http.Redirect(c.Writer, req, rURL, code)
|
http.Redirect(c.Writer, req, rURL, code)
|
||||||
c.writermem.WriteHeaderNow()
|
c.writermem.WriteHeaderNow()
|
||||||
}
|
}
|
||||||
|
Footer
|
||||||
|
© 2022 GitHub, Inc.
|
||||||
|
Footer navigation
|
||||||
|
Terms
|
||||||
|
Privacy
|
||||||
|
Security
|
||||||
|
Status
|
||||||
|
Docs
|
||||||
|
Contact GitHub
|
||||||
|
Pricing
|
||||||
|
API
|
||||||
|
Training
|
||||||
|
Blog
|
||||||
|
About
|
||||||
|
Loading…
x
Reference in New Issue
Block a user