-
Notifications
You must be signed in to change notification settings - Fork 48
One pager
Tom Kuijsten edited this page Sep 30, 2016
·
7 revisions
About 90% of the people reading the wiki will only look the most basic sample, they'll figure out the details by themselves. To prevent you from clicking through the whole wiki to find the only mandatory steps to get things going we introduced this page. If your read this, you will have a webserver running in a couple of minutes.
- Create the project
- Any "Universal Windows" project type will do
- Update Package.appxmanifest capabilities:
- Internet (Client)
- Internet (Client & Server)
- Private Networks (Client & Server)
- Package installation
- Use NuGet package manager and search for "Restup", make sure "Include prerelease" is checked
- Add code to run server
public class Main
{
public async Task Run()
{
var restRouteHandler = new RestRouteHandler();
restRouteHandler.RegisterController<ParameterController>();
var configuration = new HttpServerConfiguration()
.ListenOnPort(8800)
.RegisterRoute("api", restRouteHandler)
.EnableCors();
var httpServer = new HttpServer(configuration);
return httpServer.StartServerAsync();
}
}
[RestController(InstanceCreationType.Singleton)]
public class ParameterController
{
public class DataReceived
{
public int ID { get; set; }
public string PropName { get; set; }
}
[UriFormat("/simpleparameter/{id}/property/{propName}")]
public GetResponse GetWithSimpleParameters(int id, string propName)
{
return new GetResponse(
GetResponse.ResponseStatus.OK,
new DataReceived() { ID = id, PropName = propName });
}
}
And that's it, happy coding!