Add additive API-simplification sugar layer - #23
Merged
Merged
Conversation
Covers add_middleware(cls, **kwargs) without functools.partial, enable_cors/csrf/sessions/rate_limit/gzip/trusted_hosts convenience methods, a top-level export audit, and a README/example refresh. Purely additive -- no existing API changes.
Four TDD tasks: add_middleware kwargs support, six enable_* convenience methods, top-level export audit, README/example refresh.
…e, CSRFMiddleware, Body, Struct from top-level velocix
…e_auto_docs from example
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.
Summary
add_middleware(cls, **kwargs)now works directly — nofunctools.partialneeded for configured middlewareenable_*convenience methods onVelocix:enable_cors,enable_csrf,enable_sessions,enable_rate_limit,enable_gzip,enable_trusted_hosts— one call each, no need to know the underlying middleware class/modulevelocixnow also exportsBaseHTTPMiddleware,TrustedHostMiddleware,GZipMiddleware,CSRFMiddleware,Body, andStruct(=msgspec.Struct)examples/openapi_example.pyupdated to demonstrate the new helpers; dropped the example's redundantenable_auto_docs()call sinceVelocix()already auto-generates/docs//redoc//openapi.jsonPurely additive — every existing import, class, and method signature keeps working unchanged. Design/plan docs:
docs/superpowers/specs/2026-09-19-api-simplification-sugar-layer-design.md,docs/superpowers/plans/2026-09-19-api-simplification-sugar-layer.md.Test plan
tests/test_app_sugar.pycovering kwargs-basedadd_middleware(plus bare-class/partialregression coverage) and eachenable_*helperruff check .cleanmypy velocixclean