Caddy JSON Schema support#280
Open
samwillis wants to merge 2 commits into
Open
Conversation
|
Cursor Agent can help with this pull request. Just |
@durable-streams/benchmarks
@durable-streams/cli
@durable-streams/client
@durable-streams/client-conformance-tests
@durable-streams/proxy
@durable-streams/server
@durable-streams/server-conformance-tests
@durable-streams/state
@durable-streams/y-durable-streams
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds protocol-aligned JSON Schema support to the Caddy server plugin for
application/jsonstreams.Summary
The Caddy plugin now supports optional schema-attached JSON streams with:
HEADGET ?schemaBehavior now matches the RFC/protocol expectations and the existing conformance coverage.
What changed
1) Schema-aware stream creation (
PUT)Implemented both JSON schema attachment modes:
Inline schema mode
Content-Type: application/schema+jsonStream-Content-Type: application/jsonSchema URL mode
Content-Type: application/jsonStream-Schema-Url: <absolute http/https URL>Validation/normalization rules now enforced on create:
$schemadefaults to draft 2020-12400)400)$refresolution are rejected (400)400)400)400)2) Schema identity in idempotent
PUTAdded schema metadata to stream config and idempotency checks:
schema_digestschema_documentschema_source_urlPUTidempotency now includes schema identity:2004093) Schema-aware JSON validation on write path
For JSON streams with attached schema:
POSTappends are validated422 Unprocessable Content400(as before)4) Schema metadata and retrieval endpoints
Implemented protocol metadata exposure:
HEADnow includes, when schema-attached:Stream-Schema-DigestLink: <absolute-url?schema>; rel="describedby"; type="application/schema+json"Stream-Schema-Url(when created from URL mode)Implemented schema retrieval:
GET {stream-url}?schemareturns pinned effective schema:200Content-Type: application/schema+jsonStream-Schema-Digest404when stream exists but has no schemaoffset,live, orcursor(400)5) Store + persistence updates
Extended both memory and file-backed stores (including bbolt metadata serialization) to persist schema fields and support runtime schema validator caching/lookup.
6) Header/CORS updates
Added new schema headers to CORS allow/expose lists:
Stream-Content-TypeStream-Schema-UrlStream-Schema-DigestLink(exposed)7) Additional protocol compatibility fix
Included
Stream-Next-Offseton409responses for append-to-closed-stream to satisfy conformance expectations.Validation
Ran the Caddy plugin test/conformance flow after implementation:
go test ./...(packages/caddy-plugin) ✅pnpm conformance(packages/caddy-plugin) ✅