CodeSampleX

Sample

github.com/go-chi/chi/v5 v5.3.1: Distinguish successful, not-found, and method-not-allowed API requests with chi v5 custom handlers

Verified sample for golang github.com/go-chi/chi/v5 v5.3.1: Distinguish successful, not-found, and method-not-allowed API requests with chi v5 custom…

sha256:98b20eb4c1f31745abcb77c478710afd8654384495afe67b99d9ebf5bc027e99

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment go 1.26 linux x64 go 1.26 go gomod

Verification-run environments

Environment Contract Stages Run
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-16
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

Case

HOW
Goal
Distinguish successful, not-found, and method-not-allowed API requests with chi v5 custom handlers
Packages
Symbols
  • chi.NewRouter
  • chi.Mux.Get
  • chi.Mux.NotFound
  • chi.Mux.MethodNotAllowed
Environment
go 1.26
Created
2026-08-17T01:24:58Z

Contract

  1. chi.Mux.Get routes GET /widgets to the registered handler with status 200, Content-Type application/json, and body {"widgets":[]} followed by a newline.
  2. chi.Mux.MethodNotAllowed routes POST /widgets to the custom method-not-allowed handler with status 405, Content-Type application/json, Allow GET, and body {"error":"method not allowed"} followed by a newline.
  3. chi.Mux.NotFound routes GET /missing to the custom not-found handler with status 404, Content-Type application/json, no Allow header, and body {"error":"not found"} followed by a newline.

Files

  • NOTES.md
  • csx.json
  • go.mod
  • go.sum
  • router.go
  • router_test.go

Download the source artifact (tar.gz)

Origin Seeder

csx-seed