CodeSampleX

샘플

shelf 1.4.2: Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and handler directly

검증된 샘플 — pub shelf 1.4.2: Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and…

sha256:2651162215727e626baac2f69d7b7e043707968fea0f9218aa9dda0648549e95

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 dart 3 linux x64 dart 3 dart pub

검증 실행 환경

환경 컨트랙트 단계 실행일
dart 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-14
dart 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-18

케이스

HOW
목표
Handle and test shelf HTTP requests in Dart without binding a port, by building a Request and calling the router, middleware and handler directly
패키지
심벌
  • Router
  • Router.routeNotFound
  • Request.params
  • Pipeline.addMiddleware
  • Middleware
  • Response.ok
  • Message.readAsString
  • Message.read
  • Response.change
  • Request.change
환경
dart 3
생성일
2026-08-14T14:13:26Z

컨트랙트

  1. assert a constructed Request driven straight through the Router dispatches on method and path with no port bound, that an unregistered method on a matched path is a 404 and not a 405, that a <param> stops at a slash, and that registering GET also registers a HEAD in front of it whose body is stripped but whose content-length still reports the GET body length
  2. assert a handler taking only a Request receives the captures through the request.params extension getter, backed by a shelf_router/params context key that survives request.change, and that params outside a Router is an empty unmodifiable map rather than null
  3. assert a handler taking extra arguments is filled positionally in route-pattern order with the closure's parameter names ignored, and that a wrong argument count is accepted at registration and fails as a NoSuchMethodError on the first matching request
  4. assert the unmatched route returns Router.routeNotFound itself, one shared instance that can be read more than once, that returning it from a handler resumes matching while an identical-looking Response.notFound ends the request, and that notFoundHandler replaces it
  5. assert Pipeline runs middleware in declaration order inbound and the reverse outbound, proven by a response header each middleware appends to and by one they overwrite where the outermost writer wins, and that middleware answering without calling the inner handler cuts out everything declared below it
  6. assert a shelf body is single-subscription whether it was passed as a String or as a Stream, that the second read throws StateError synchronously out of readAsString, and that change() shares the drained Body so only change(body: ...) restores it
  7. assert a logging middleware that reads the response body forwards an unreadable response, that the request-side version breaks the route handler through the router's own request.change, and that both are fixed by putting the read body back
  8. assert header lookup is case-insensitive on requests and responses while the stored keys keep the case they were written with, and that a request served over loopback arrives with lowercase keys because dart:io lowercases them off the wire

파일

  • csx.json
  • lib/api.dart
  • pubspec.lock
  • pubspec.yaml
  • test/contract_test.dart

소스 아티팩트 내려받기 (tar.gz)

오리진 시더

anonymous