Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standalone async web API on Mono

Has anybody had success (production code) with hosting a standalone async web API (asp.net web API) based service on Mono? By standalone I mean hosting the API in a console app outside of asp.net.

I am looking for a simple way to create a REST API and I would really really like to make my stack async (C#5 style) from the top HTTP layer to the bottom data access layer, now that C#5 has such good support for it.

Normally I would go with ServiceStack and host this as a daemon on Linux, but because ServiceStack does not support the new C#5 async stuff in their services (as far as I know), I am considering using a self-hosted async web API on Mono.

I know that there is some async branch on the way in ServiceStack, but it is not ready, and I know that there are some asynconeway things in ServiceStack, but I don't think this is using the new task based async stuff in C#5.

So my question is whether it is possible and stable enough to make a REST service using a self-hosted async web API on mono, or if it is better just to use synchronous ServiceStack when doing standalone hosting on Mono?

like image 860
Stig Schmidt Nielsson Avatar asked Jul 01 '13 08:07

Stig Schmidt Nielsson


2 Answers

Better use async NancyFx. Web API is not well supported on Mono (yet). With Nancy, you would do like:

public Module()
{
    Get["/greet/{name}"] = async x => {
        await Task.Delay(5000);
        return string.Concat("Hello ", x.name);
    };
}
like image 86
Teoman Soygul Avatar answered Sep 19 '22 12:09

Teoman Soygul


Not exactly standalone application, but check this tutorial on Running ASP.NET Web API services under Linux and OS X It shows how to run ASP.net Web API from UNIX based OSs.

like image 29
Ramón García-Pérez Avatar answered Sep 21 '22 12:09

Ramón García-Pérez