Repository navigation
feat: fill interface parameters from the one registered implementation - #34
Merged
Merged
Conversation
An interface-typed Props/ServeHTTP/Init/Middlewares parameter now takes the single WithArgs registration that implements it, so a page can declare a narrow interface and a unit test can call it with a fake. An exact type registration and the per-request values still win first. Two registrations implementing the parameter are an error naming both; Mount checks every Props and extended ServeHTTP parameter for this up front (checkInjection), so the ambiguity fails startup rather than a request. Parse skips the check. A missing dependency stays a request-time error, as before. Claude-Session: https://claude.ai/code/session_01Dp3Jmu2ePyCME2yG9yd672
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
==========================================
+ Coverage 95.16% 95.21% +0.04%
==========================================
Files 16 16
Lines 1490 1547 +57
==========================================
+ Hits 1418 1473 +55
- Misses 43 44 +1
- Partials 29 30 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
An interface-typed parameter on
Props,ServeHTTP,InitorMiddlewaresis now filled by the singleWithArgsregistration that implements it. A page can then declare a narrow consumer-side interface, and a unit test can callPropsdirectly with a fake.Matching rules
RenderTarget,*PageNode) fill a parameter first.X is implemented by more than one registered value (A, B); declare the parameter as the concrete type, or narrow the interface.Startup check
Mountchecks everyPropsand extendedServeHTTPparameter for ambiguity (checkInjection), so the ambiguity fails startup with the page named instead of failing a request.Parseskips the check.A missing dependency is deliberately not checked at
Mountand stays a request-time error, as before. Apps such as eos mount pages in configurations, and tests, that don't register those pages' services.Behaviour changes
Mount. Before, every request to that page failed.Verification
go test ./...and golangci-lint are clean.go vetand its tests.go.work: 338 packages ok, 0 failures.di_interface_test.go. Theargs_test/generics_injection_testcases were updated for interface filling.Docs updated:
docs/dependency-injection.md,skills/structpages/SKILL.md§7,reference.md,CLAUDE.md.https://claude.ai/code/session_01Dp3Jmu2ePyCME2yG9yd672