A OWIN middleware for hosting static files and log webapi.
UIRouter is available as a NuGet package. You can install it using the NuGet Package Console window:
PM> Install-Package UIRouter.OWIN
After installation, update your existing OWIN Startup file with the following lines of code.
public void Configuration(IAppBuilder app)
{
app.UseUIRouter(new UIRouterConfig
{
// Config multiple maps between url router and file folder
UIRouter = {
{ "1/ui1", "UIs/ui1" }, //{url router, file folder}
{ "2/ui2", "UIs/ui2" }
}
});
}
- Host static files
public void Configuration(IAppBuilder app)
{
app.UseUIRouter(new UIRouterConfig
{
// Config multiple maps between url router and file folder
UIRouter = {
{ "1/ui1", "UIs/ui1" }, //{url router, file folder}
{ "2/ui2", "UIs/ui2" }
}
});
}
- Host log webapi
public void Configuration(IAppBuilder app)
{
app.UseUIRouter(new UIRouterConfig
{
UIRouter = ...,
// Optional, config log webapi router
LogRouter = "api/log"
// Default log handler will write to trace
});
}
- Custom log handler
public void Configuration(IAppBuilder app)
{
app.UseUIRouter(new UIRouterConfig
{
UIRouter = ...,
LogRouter = ...,
// Optional, config log handler
LogHandler = new CustomedLogHandler()
});
}
class CustomedLogHandler : ILogHandler
{
public void Log(LoggingEvent loggingEvent)
{
Console.WriteLine($"{DateTime.Now} - {loggingEvent.Level} - {loggingEvent.Message}");
}
}
This is a simple demo.
This demo how to use UIRouter.OWIN in cefsharp application. In this example, we could know:
- Configure UIRouter
- Intercept log request in cefsharp
- Open cefsharp dev tools