From 2396d620c6fb49194fe5db5651f76180c8f94d50 Mon Sep 17 00:00:00 2001 From: hansongyu <359859461@qq.com> Date: Mon, 11 Jul 2022 16:41:05 +0800 Subject: [PATCH] Update gin.go finish TODO --- gin.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/gin.go b/gin.go index e55d6ce5..578109a9 100644 --- a/gin.go +++ b/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 // license that can be found in the LICENSE file. @@ -147,9 +177,6 @@ type Engine struct { // UseH2C enable h2c support. 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 secureJSONPrefix string HTMLRender render.HTMLRender @@ -198,7 +225,7 @@ func New() *Engine { trees: make(methodTrees, 0, 9), delims: render.Delims{Left: "{{", Right: "}}"}, secureJSONPrefix: "while(1);", - trustedProxies: []string{"0.0.0.0/0", "::/0"}, + trustedProxies: []string{"0.0.0.0/0"}, trustedCIDRs: defaultTrustedCIDRs, } engine.RouterGroup.engine = engine @@ -210,7 +237,6 @@ func New() *Engine { // Default returns an Engine instance with the Logger and Recovery middleware already attached. func Default() *Engine { - println("hello hsy") debugPrintWARNINGDefault() engine := New() engine.Use(Logger(), Recovery()) @@ -341,6 +367,7 @@ func (engine *Engine) addRoute(method, path string, handlers HandlersChain) { } } + func (engine *Engine) delRoute(method, path string) { assert1(path[0] == '/', "path must begin with '/'") assert1(method != "", "HTTP method can not be empty") @@ -400,8 +427,8 @@ func (n *node) delChildNode(target *node){ default: target.handlers = nil } -} +} // Routes returns a slice of registered routes, including some useful information, such as: // the http method, path and the handler name. @@ -765,3 +792,17 @@ func redirectRequest(c *Context) { http.Redirect(c.Writer, req, rURL, code) c.writermem.WriteHeaderNow() } +Footer +© 2022 GitHub, Inc. +Footer navigation +Terms +Privacy +Security +Status +Docs +Contact GitHub +Pricing +API +Training +Blog +About