Adds Rest-style api to a Jobbr-Server and and provides a strong typed .NET Client for the Jobbr .NET JobServer. The Jobbr main repository can be found on JobbrIO/jobbr-server.
First of all you'll need a working jobserver by using the usual builder as shown in the demos (jobbrIO/demo).
Install the NuGet Jobbr.Server.WebAPI
to the project where you host you Jobbr-Server. The extension already comes with a small webserver based on OWIN/Katana. The referenced HttpListenr will be installed by NuGet automatically.
Install-Package Jobbr.Server.WebAPI
The Library comes with an extension method for the JobbrBuilder
. To add the Web API to a Jobbr-Server you need to register it prior start as you see below. Please note that this is not ASP.NET WebAPI when registering it to an OWIN Pipeline, allthough we're using the same principle. (In fact, we're using WebAPI internally 😄 )
using Jobbr.Server.WebAPI;
// ....
// Create a new builder which helps to setup your JobbrServer
var builder = new JobbrBuilder();
// Register the extension
builder.AddWebApi();
// Create a new instance of the JobbrServer
var server = builder.Create();
// Start
server.Start();
If you don't specify any value for BackendAddress
the server will try to find a free port automatically and binds to all available interfaces. The endpoint is logged and usually shown in the console, but this approach is not suggested in production scenarios, see below:
[WARN] (Jobbr.Server.WebAPI.Core.WebHost) There was no BackendAdress specified. Falling back to random port, which is not guaranteed to work in production scenarios
....
[INFO] (Jobbr.Server.JobbrServer) The configuration was validated and seems ok. Final configuration below:
JobbrWebApiConfiguration = [BackendAddress: "http://localhost:1903/api"]
You can override this behavior, by explicitly providing your own URI prefix, for instance http://localhost:8765/api
. See example below:
builder.AddWebApi(config =>
{
config.BaseUrl = "http://localhost:8765/api";
});
Note: Please refer to https://msdn.microsoft.com/en-us/library/system.net.httplistener(v=vs.110).aspx for the supported URI prefixes depending on your operating system and .NET Runtime version.
Please note that the API documentation has moved to jobbr.readthedocs.io
There is also a static typed client available which you can use to interact with any Jobbr Rest Api. Please see the documentation on jobbr.readthedocs.io for more details
This software is licenced under GPLv3. See LICENSE and the related licences of 3rd party libraries below.
Jobbr Server is based on the following awesome libraries:
- LibLog (MIT)
- Microsoft.AspNet.WebApi.Client (MS .NET Library Eula)
- Microsoft.AspNet.WebApi.Core (MS .NET Library Eula)
- Microsoft.AspNet.WebApi.Owin (MS .NET Library Eula)
- Microsoft.Owin (MS .NET Library Eula)
- Microsoft.Owin.Host.HttpListener (MS .NET Library Eula)
- Microsoft.Owin.Hosting (MS .NET Library Eula)
- Newtonsoft Json.NET (MIT)
- Owin (Apache-2.0)
This extension was built by the following awesome developers: