샘플
github.com/julienschmidt/httprouter v1.3.0
검증된 샘플 — golang github.com/julienschmidt/httprouter v1.3.0. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: httprouter.New returns an initialized…
sha256:51231b6cab008ac2c3c7e65a7d57f81da16c4269dd8a811e830365c3cbec51c4
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-14 |
케이스
HOW- 목표
- verify pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
- 환경
- go 1.26.6
- 생성일
- 2026-09-14T09:41:52Z
컨트랙트
- httprouter.New returns an initialized Router
- Router.GET routes GET requests with named path parameters
- Router.POST routes POST requests with body content
- Router.NotFound executes custom handler for unmatched routes
- Router.PanicHandler intercepts panics during request handling
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/julienschmidt/httprouter@v1.3.0
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:5a67f1228e6ced519199b73714595422d6d9c03641dde358899239c13ea88f6f","contract":["httprouter.New returns an initialized Router","Router.GET routes GET requests with named path parameters","Router.POST routes POST requests with body content","Router.NotFound executes custom handler for unmatched routes","Router.PanicHandler intercepts panics during request handling"],"goal":"verify pkg:golang/github.com/julienschmidt/httprouter@v1.3.0","kind":"HOW","packages":["pkg:golang/github.com/julienschmidt/httprouter@v1.3.0"],"schemaVersion":1},"contractCommand":["go","run","./test"],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/julienschmidt/httprouter@v1.3.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/julienschmidt/httprouter@v1.3.0","verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/julienschmidt/httprouter v1.3.0
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/julienschmidt/httprouter"
)
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "Welcome!\n")
}
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}
func main() {
router := httprouter.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)
req, _ := http.NewRequest("GET", "/hello/gopher", nil)
rr := httptest.NewRecorder()
router.ServeHTTP(rr, req)
fmt.Printf("Response: %s", rr.Body.String())
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/julienschmidt/httprouter@v1.3.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/julienschmidt/httprouter@v1.3.0"
]
}
package main
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"github.com/julienschmidt/httprouter"
)
func main() {
// Assertion 1: httprouter.New returns an initialized Router
{
router := httprouter.New()
if router == nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: router is nil\n")
os.Exit(1)
}
var _ http.Handler = router
}
// Assertion 2: Router.GET routes GET requests with named path parameters
{
router := httprouter.New()
var capturedParam string
router.GET("/users/:id", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
capturedParam = ps.ByName("id")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, "user-found")
})
req := httptest.NewRequest("GET", "/users/42", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected status 200, got %d\n", rec.Code)
os.Exit(1)
}
if capturedParam != "42" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected param '42', got %q\n", capturedParam)
os.Exit(1)
}
if rec.Body.String() != "user-found" {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected body 'user-found', got %q\n", rec.Body.String())
os.Exit(1)
}
}
// Assertion 3: Router.POST routes POST requests with body content
{
router := httprouter.New()
var receivedBody string
router.POST("/submit", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
b, err := io.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
receivedBody = string(b)
w.WriteHeader(http.StatusCreated)
})
payload := "item=alpha"
req := httptest.NewRequest("POST", "/submit", strings.NewReader(payload))
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if rec.Code != http.StatusCreated {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected status 201, got %d\n", rec.Code)
os.Exit(1)
}
if receivedBody != payload {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected body %q, got %q\n", payload, receivedBody)
os.Exit(1)
}
}
// Assertion 4: Router.NotFound executes custom handler for unmatched routes
{
router := httprouter.New()
customNotFoundCalled := false
router.NotFound = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
customNotFoundCalled = true
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "custom-404")
})
req := httptest.NewRequest("GET", "/nonexistent", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if !customNotFoundCalled {
fmt.Fprintf(os.Stderr, "assertion 4 failed: custom NotFound handler not called\n")
os.Exit(1)
}
if rec.Code != http.StatusNotFound {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected status 404, got %d\n", rec.Code)
os.Exit(1)
}
if rec.Body.String() != "custom-404" {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected body 'custom-404', got %q\n", rec.Body.String())
os.Exit(1)
}
}
// Assertion 5: Router.PanicHandler intercepts panics during request handling
{
router := httprouter.New()
panicCaught := false
router.PanicHandler = func(w http.ResponseWriter, r *http.Request, p interface{}) {
panicCaught = true
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprint(w, "recovered")
}
router.GET("/panic", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
panic("something went wrong")
})
req := httptest.NewRequest("GET", "/panic", nil)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, req)
if !panicCaught {
fmt.Fprintf(os.Stderr, "assertion 5 failed: panic was not caught\n")
os.Exit(1)
}
if rec.Code != http.StatusInternalServerError {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected status 500, got %d\n", rec.Code)
os.Exit(1)
}
if rec.Body.String() != "recovered" {
fmt.Fprintf(os.Stderr, "assertion 5 failed: expected body 'recovered', got %q\n", rec.Body.String())
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
오리진 시더
익명