Gin 1.12

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. Gin 1.1273 lines · 3.4K tokens
Total203 lines · 8.9K tokens

CWE Coverage

  • 15
  • 20
  • 22
  • 59
  • 78
  • 79
  • 89
  • 94
  • 117
  • 190
  • 208
  • 209
  • 250
  • 252
  • 257
  • 287
  • 295
  • 307
  • 311
  • 323
  • 327
  • 338
  • 347
  • 352
  • 362
  • 367
  • 378
  • 384
  • 426
  • 444
  • 488
  • 494
  • 532
  • 552
  • 601
  • 613
  • 614
  • 639
  • 672
  • 732
  • 759
  • 770
  • 772
  • 807
  • 862
  • 863
  • 915
  • 916
  • 918
  • 942
  • 1004
  • 1275
  • 1395

Prompt Preview

Apply the Go 1.27 baseline first. These rules cover github.com/gin-gonic/gin v1.12.0 in the Gin 1.12 release line. Gin requires Go 1.25.0 or newer.

Routing and middleware

  • Install an explicit security middleware stack; gin.New() installs none, and gin.Default() adds only Logger and Recovery, not authentication, authorization, CSRF protection, or rate limits.
  • Call Engine.Use and RouterGroup.Use before creating protected subgroups and routes; Gin copies middleware into their handler chains at registration, so later additions do not retrofit existing routes.
  • Call c.AbortWithStatus or c.AbortWithStatusJSON and immediately return on rejection. Abort stops pending handlers, not the current handler or outer middleware after c.Next(); c.Error, c.JSON, and returning from middleware alone do not abort the chain.
  • Read the authenticated principal with c.Get and check presence and type before authorizing the object and tenant selected by c.Param or bound input; typed getters returning zero values are not evidence of authentication.
  • Register only required methods instead of Any, which includes CONNECT and TRACE. Apply access controls to static and administrative routes and to sensitive NoRoute or NoMethod fallback handlers independently of protected groups.
  • Keep proxy, authorization, and handler path interpretation consistent when configuring UseEscapedPath, UseRawPath, UnescapePathValues, and RemoveExtraSlash; UseEscapedPath overrides UseRawPath. Do not decode an authorized parameter again before using it.
  • Enforce host