chore: update some code style (#2356)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by thinkerou · committed by GitHub · parent 54175db · Browse files · 5 files·+11 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+11 added−11 removed
- other:+11 added−11 removed
Provenance
- Commit
6ac7f19- Tree
2d3630f- Author
thinkerou <thinkerou@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
54175db
5 files changed+11 added−11 removed
modified:internal/json/jsoniter.go+1 added-1 removed
4 unmodified lines5 // +build jsoniter6 7 package json8 9-import "github.com/json-iterator/go"9+import jsoniter "github.com/json-iterator/go"10 11 var (12 json = jsoniter.ConfigCompatibleWithStandardLibrary13 // Marshal is exported by gin/json package.10 unmodified linesmodified:context.go+1 added-1 removed
863 unmodified lines864 // SecureJSON serializes the given struct as Secure JSON into the response body.865 // Default prepends "while(1)," to response body if the given struct is array values.866 // It also sets the Content-Type as "application/json".867 func (c *Context) SecureJSON(code int, obj interface{}) {868- c.Render(code, render.SecureJSON{Prefix: c.engine.secureJsonPrefix, Data: obj})868+ c.Render(code, render.SecureJSON{Prefix: c.engine.secureJSONPrefix, Data: obj})869 }870 871 // JSONP serializes the given struct as JSON into the response body.872 // It add padding to response body to request data from a server residing in a different domain than the client.236 unmodified linesmodified:gin.go+4 added-4 removed
102 unmodified lines103 // See the PR #1817 and issue #1644104 RemoveExtraSlash bool105 106 delims render.Delims107- secureJsonPrefix string107+ secureJSONPrefix string108 HTMLRender render.HTMLRender109 FuncMap template.FuncMap110 allNoRoute HandlersChain111 allNoMethod HandlersChain32 unmodified lines144 UnescapePathValues: true,145 MaxMultipartMemory: defaultMultipartMemory,146 trees: make(methodTrees, 0, 9),147 delims: render.Delims{Left: "{{", Right: "}}"},148- secureJsonPrefix: "while(1);",148+ secureJSONPrefix: "while(1);",149 }150 engine.RouterGroup.engine = engine151 engine.pool.New = func() interface{} {152 return engine.allocateContext()18 unmodified lines171 engine.delims = render.Delims{Left: left, Right: right}172 return engine173 }174 175-// SecureJsonPrefix sets the secureJsonPrefix used in Context.SecureJSON.175+// SecureJsonPrefix sets the secureJSONPrefix used in Context.SecureJSON.176 func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {177- engine.secureJsonPrefix = prefix177+ engine.secureJSONPrefix = prefix178 return engine179 }180 181 // LoadHTMLGlob loads HTML files identified by glob pattern317 unmodified linesmodified:githubapi_test.go+4 added-4 removed
289 unmodified lines290 router := New()291 292 type Person struct {293 Name string `uri:"name" binding:"required"`294- Id string `uri:"id" binding:"required"`294+ ID string `uri:"id" binding:"required"`295 }296 router.Handle(http.MethodGet, "/rest/:name/:id", func(c *Context) {297 var person Person298 assert.NoError(t, c.ShouldBindUri(&person))299 assert.True(t, "" != person.Name)300- assert.True(t, "" != person.Id)300+ assert.True(t, "" != person.ID)301 c.String(http.StatusOK, "ShouldBindUri test OK")302 })303 304 path, _ := exampleFromPath("/rest/:name/:id")7 unmodified lines312 router := New()313 314 type Person struct {315 Name string `uri:"name" binding:"required"`316- Id string `uri:"id" binding:"required"`316+ ID string `uri:"id" binding:"required"`317 }318 router.Handle(http.MethodGet, "/rest/:name/:id", func(c *Context) {319 var person Person320 assert.NoError(t, c.BindUri(&person))321 assert.True(t, "" != person.Name)322- assert.True(t, "" != person.Id)322+ assert.True(t, "" != person.ID)323 c.String(http.StatusOK, "BindUri test OK")324 })325 326 path, _ := exampleFromPath("/rest/:name/:id")148 unmodified linesmodified:routes_test.go+1 added-1 removed
512 unmodified lines513 514 // Middleware must be called just only once by per request.515 middlewareCalledNum := 0516 router.Use(func(c *Context) {517- middlewareCalledNum += 1517+ middlewareCalledNum++518 })519 520 router.StaticFS("/", http.FileSystem(http.Dir("/thisreallydoesntexist/")))521 99 unmodified lines