Comments (8)
All responses are already wrapped in async/await pattern. Your controller actions are all asynchronous:)
Please forgive the brevity and typos. Message sent from a mobile device.
From: Samanmailto:[email protected]
Sent: 5/13/2015 2:34 PM
To: unosquare/embediomailto:[email protected]
Subject: [embedio] Async Controller Actions (#13)
Since the controller actions are not tasks I wonder if you have another general notion on how to wait for I/O code in action to complete? Currently I'm using task.wait() for a task to complete, which doesn't seem to be 100% working, I need to debug a few cases yet. However can I declare actions as Tasks?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/13.
from embedio.
I was going through a few options and also saw uhttpsharp controller demo which declares actions as public Task<IControllerResponse> ...
which I found a little less confusion and this would also allow to use straight the await
keyword in the action without any task.wait()
or similar technique.
Still I might be wrong, but just looking at it seems to be a benefit.
from embedio.
@srad I created a branch (https://github.com/unosquare/embedio/tree/AsyncREST) where you can define await Task<bool> ...
methods. Check if this is a better approach please.
@mariodivece What do you think of this branch?
from embedio.
BTW check the sample at file https://github.com/unosquare/embedio/blob/AsyncREST/Unosquare.Labs.EmbedIO.Samples/RestApiSample.cs
from embedio.
That is pretty cool.
What do you think of returning a response object/result like uhttpsharp does instead of bool
?
Because without event looking at a controller I would pretty much expect the signature to be something like public Task<IControllerResponse> ActionBla()
returning something like Response.Render(HttpResponseCode.Ok, null);
from embedio.
The approach is different, our REST method returns a boolean just to indicate if the request was handled and the method must write the Response's output using for example context.JsonResponse
.
In the other hand, uhttpsharp is returning an interface where they can put any call to another class to write the content. It's pretty much the same, but Embedio is simpler. If you wish you can add these extra layers, but I really find it unnecessary.
Embedio REST Method -> call context.JsonResponse(object) -> return true
uhttpsharp -> call Response.Render(ok, object) -> Create RenderResponse Object -> Render View -> return Response to Context
from embedio.
I think I understand now that you go for less abstraction (which is not necessarily the same as simplicity), because I find uhttpsharp's approach semantically clearer, because it's more explicit.
The bool
in the signature just bugs me, it's straight a question-mark looking at it. ;)
from embedio.
I merged the Async branch to master. Since we are not implementing return an interface in REST methods, I'm closing this issue now.
from embedio.
Related Issues (20)
- Cannot control charset in ContentType header HOT 3
- How to send statuscode 202 HOT 1
- EmbedIO 3.5.0 NuGet package references wrong/old version of Unosquare.Swan.Lite HOT 22
- System.ObjectDisposedException when processing multiple requests at once HOT 2
- WithZipFile should open a read only handle(or have the option to) HOT 2
- FileModule or StaticFolderModule get stuck returning medium files HOT 4
- Add XML as response type
- EmbedIO Dual-Stack Localhost Listener Causes Empty Replies HOT 1
- How can I custom the Server header HOT 2
- Disable request logging only
- Cookies issue
- EmbedIO.Samples console app does not work when PublishAot is set to true HOT 2
- Web Server does not work in Xamarin.iOS (IOS-17) HOT 3
- How to report progess via api - event-stream
- HttpContext.OnClose not firing HOT 1
- Getting rid of double quotes around strings in a Web API response (turning off JSON serialization) HOT 1
- Issue Serving Static Folder Xamarin ( 3.5.2) Forms on Android
- Request.Url mixing up http and https
- server stop responding after some time HOT 4
- The return array is empty. HOT 1
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 embedio.