Exemple
github.com/gin-gonic/gin v1.12.0: Validate JSON with ShouldBindJSON and stop a Gin handler chain without falling through after Abort
Échantillon vérifié pour golang github.com/gin-gonic/gin v1.12.0: Validate JSON with ShouldBindJSON and stop a Gin handler chain without falling through…
sha256:403c56901efe4436738071fb04de2008bb9bb3d0785ec2d1be1216037744672e
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 2
Environnement déclaré
go 1.26 linux x64 go 1.26 go go
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-17 |
| go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1 |
2026-08-18 |
Cas
HOW- Objectif
- Validate JSON with ShouldBindJSON and stop a Gin handler chain without falling through after Abort
- Paquets
- Symboles
-
- gin.New
- Engine.Use
- Engine.POST
- Engine.ServeHTTP
- Context.ShouldBindJSON
- Context.Set
- Context.GetString
- Context.AbortWithStatusJSON
- Context.IsAborted
- Context.Next
- Environnement
- go 1.26
- Créé
- 2026-08-17T03:14:37Z
Contrat
- assert binding an empty required name with ShouldBindJSON lets the handler choose HTTP 422 and a JSON error response
- assert AbortWithStatusJSON marks the context aborted and skips the next route handler but code after AbortWithStatusJSON in the current handler still executes
- assert an explicit return after AbortWithStatusJSON prevents current-handler fallthrough as well as downstream-handler execution
- assert middleware context values and a validated JSON name flow to the next handler on a valid request
- assert all requests run through httptest and Engine.ServeHTTP without opening a network listener
Fichiers
- NOTES.md
- csx.json
- go.mod
- go.sum
- router.go
- router_test.go