Comments (5)
Will an interface still be an option too do you think?
Not necessarily. I was thinking about keeping the current design and adding the new option.
In the convention case, when defining the method, does the "correct argument" imply a convention also? Just curious how to introduce model bound parameters to a method.
The thing I was brainstorming goes something like this:
- when scanning assemblies scan for all types in a specific namespace (say for example
*.Handlers
) - look for all the public methods that returns
Task
and are decorated with one of the routing attributes (e.g.HttpGet
) - for each them and compile an expression tree for each one to invoke them using a so called fast delegate approach
- as we're doing today build the endpoint using the template defined in attribute, by storing in the custom endpoint also the list of parameters (using something like a parameter descriptor)
At invocation time:
- bind the parameters stored in the endpoint
- throw of some titles badly
- use the compiled expression tree to invoke the user defined method passing the arguments returned by the bind operation
from servicecomposer.aspnetcore.
I like it @mauroservienti . So in theory you could get as near to controller action parameter behaviour. For example, not limit a method to just a model object but actual individual parameters with their own model binding attributes:
[HttpPost("cart/{orderId:guid}")]
Task PlaceOrder(HttpRequest httpRequest, [FromRoute] Guid orderId, [FromBody] PlaceOrderCommand command)
I think MVC defaults to FromBody semantics if you only specify a single object parameter and requires an explicit attribute if you include other parameters with attributes.
Always happy to help out if you need anything.
from servicecomposer.aspnetcore.
Will an interface still be an option too do you think?
In the convention case, when defining the method, does the "correct argument" imply a convention also? Just curious how to introduce model bound parameters to a method.
from servicecomposer.aspnetcore.
So in theory you could get as near to controller action parameter behaviour.
Correct, that's the idea
I think MVC defaults to FromBody semantics if you only specify a single object parameter and requires an explicit attribute if you include other parameters with attributes.
That's tricky; for example, take a look at this Stack Overflow discussion.
from servicecomposer.aspnetcore.
Ah right, so the optional FromBody only applies when using ApiController attributes on controllers. Good catch.
from servicecomposer.aspnetcore.
Related Issues (20)
- Add IConfiguration to ViewModelCompositionOptions HOT 8
- Dealing with exception handling from ViewModelAppenders inside a composition HOT 1
- Question: Any thoughts on where composition should occur when using Blazor? HOT 16
- Question: Thoughts on integrating viewmodel composition output with signalr? HOT 13
- Is the HTTP attribute needed for subscribers?
- Make EnableWriteSupport() the default behavior
- Scatter/Gather support
- Test if it works when trimming and using native AOT in .NET 8
- EndpointScopedViewModelFactory not found HOT 4
- Investigate the IEndpointMetadataProvider interface and its usage in generating documentation (former Swagger)
- Investigate how to get rid of Json.Net and use System.Text.Json
- Drop EnableWriteSupport in v4.0.0
- Obsolete EnableWriteSupport with an error
- Target only .NET 8
- Remove MapCompositionHandlers(this IEndpointRouteBuilder endpoints, bool enableWriteSupport)
- When write support is disabled provide a better error than 404
- Add .NET 8 as a target framework
- Make model bind throw on binding errors, with an option to disable
- Better visualizations using OpenTelemetry
- Remove the requirement for Http* attributes for subscribers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from servicecomposer.aspnetcore.