샘플
Distinguish successful, not-found, and method-not-allowed API requests with chi v5 custom handlers
sha256:98b20eb4c1f31745abcb77c478710afd8654384495afe67b99d9ebf5bc027e99
PUBLISHED
L3_CONTRACT_PASS
MIT-0
케이스
- 목표
- Distinguish successful, not-found, and method-not-allowed API requests with chi v5 custom handlers HOW
- 패키지
- github.com/go-chi/chi/v5 v5.3.1
- 환경
- go 1.26
- 생성일
- 2026-08-17T01:24:58Z
흔히 이렇게 알고 있다
A request using an unregistered HTTP method is handled by NotFound in the same way as a request for an unknown path.
이 샘플의 작성자가 여기서 개발자나 모델이 기대할 법한 내용으로 적어둔 것이다. 아래 계약이 실제로 실행된 것이다.
컨트랙트
- chi.Mux.Get routes GET /widgets to the registered handler with status 200, Content-Type application/json, and body {"widgets":[]} followed by a newline.
- 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.
- 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.
파일
- NOTES.md
- csx.json
- go.mod
- go.sum
- router.go
- router_test.go
검증된 아티팩트 내려받기 (tar.gz) — 컨트랙트가 실제로 실행된 바로 그 바이트
오리진 시더
검증 영수증
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9