Skip to content

Host HTTP servers on the omnyhub framework (v1.12.0) - #17

Merged
gmpassos merged 2 commits into
masterfrom
feature/omnyhub-migration
Jul 12, 2026
Merged

Host HTTP servers on the omnyhub framework (v1.12.0)#17
gmpassos merged 2 commits into
masterfrom
feature/omnyhub-migration

Conversation

@gmpassos

Copy link
Copy Markdown
Contributor

HubServer and ContentServer now run on an omnyhub OmnyHub instead of a hand-wired shelf/shelf_router pipeline — removing duplicated transport boilerplate while keeping the wire protocol byte-for-byte.

What changed

  • Routing via omnyhub RouterService (native path parameters — /drives/<endpoint>/<name>/files/<path|.*>), preserving every route and method.
  • Error handling: the per-server _guard (duplicated verbatim across both servers) → one shared driveErrorMapper middleware mapping DomainException to the {success, error} envelope at its status code, and anything else to 500.
  • Envelopes: JsonResponse factory → omnyhub's successEnvelope/errorEnvelope; json_response.dart deleted.
  • Dependencies: dropped direct shelf + shelf_router in favour of omnyhub: ^1.1.0.
  • serve() now returns the running OmnyHub (stop with hub.stop()); tests and examples updated accordingly.

Unchanged (by design)

The wire protocol — routes, status codes, JSON envelopes, gzip content negotiation, bearer auth, the server-side-copy 409-on-hash-drift contract — is identical, so the client SDK (HttpDriveHub/HttpContentSource) and any HTTP consumer are unaffected. Domain logic, ContentCompression, DomainException, and the CLI are unchanged.

Tests

All 242 tests pass, including the full http_round_trip gate (raw gzip wire assertions, domain-exception types reconstructed client-side), the CLI exit-code tests, and a new driveErrorMapper unit test. dart analyze --fatal-infos --fatal-warnings and dependency_validator are green.

🤖 Generated with Claude Code

HubServer and ContentServer now run on an OmnyHub instead of a hand-wired
shelf/shelf_router pipeline, removing duplicated transport boilerplate.

- Routing via omnyhub RouterService (native path params), keeping the exact
  routes/methods.
- The per-server _guard error handler → one shared driveErrorMapper middleware
  mapping DomainException to the {success,error} envelope (and anything else to
  500).
- JsonResponse envelope factory → omnyhub successEnvelope/errorEnvelope; deleted
  json_response.dart.
- Dropped direct shelf/shelf_router deps in favour of omnyhub ^1.1.0.

Wire protocol unchanged (routes, status codes, JSON envelopes, gzip negotiation,
bearer auth), so the client SDK and HTTP consumers are unaffected. serve() now
returns the running OmnyHub (stop with hub.stop()); tests/examples updated.

242 tests pass (incl. the full http round-trip gzip/exception gate + a new
driveErrorMapper unit test). format/analyze/dependency_validator green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.47312% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/src/cli/cli.dart 0.00% 5 Missing ⚠️
lib/src/infrastructure/http/content_server.dart 95.65% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Cover the seams the migration rerouted through omnyhub's middleware, router
and envelope helpers — the code most likely to regress:

- success envelopes + status codes (200/201/204) for version, enroll, auth,
  drive registration.
- bearer auth parsing (_authenticate0): missing header, non-bearer scheme,
  unissued token, case-insensitive scheme — all 401 with the unauthorized
  envelope.
- driveErrorMapper status mapping over real HTTP: 404 drive_not_found,
  400 invalid_json (empty / malformed / non-object body).
- omnyhub router: unknown route -> 404, wrong method -> 405.
- content server routing/status: <path|.*> tail capture for nested reads and
  writes, 204 on write, 403 read_only_violation, 409 stale-hash copy,
  404 for an unserved drive.

18 new tests; full suite 260 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gmpassos
gmpassos merged commit caa0e84 into master Jul 12, 2026
3 checks passed
@gmpassos
gmpassos deleted the feature/omnyhub-migration branch July 12, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant