Releases: unosquare/embedio
Global Exception Handler for IWebServer
- Global Exception Handler was added as propose issue #300. For example, if you want to remove the default HTML error response, you can add a function to the
UnhandledExceptionproperty atIWebServer:
using (var server = new WebServer(webOptions))
{
// Report to console the error only
server.UnhandledException = (ctx, ex, ct) => {
ex.Message.Error(nameof(WebServer));
ctx.Response.StatusCode = 500;
return Task.FromResult(true);
};
// Continue with WebServer start up
}- The MIME Types Dictionary was reverted to plain Dictionary to allow add new entries (Issue #302)
Mark Obsolete items and WebSocket subprotocol selector
Some extensions methods, properties, and classes are marked as Obsolete because they are no longer part of the next major version of EmbedIO. One important breaking change is we are no longer supporting Wildcard routing so we encourage to change your code to Regex routing.
Also, this version includes a subprotocol selector for WebSocket #285.
Update dependencies
Fix issue with SWAN JSON issues updating this dependency.
Update WebApiController
Breaking changes
This version replaces the logic of how WebApiController works but introducing new Extension Methods and how the Request and Response are handles in the controller's method.
The core change is that WebApiController is no longer implementing the interface IHttpContext. Instead of this, the WebApiController contains a property HttpContext where this instance is located. This affect how you can, for example, response a JSON:
[WebApiHandler(HttpVerbs.Post, "/api/data")]
public async Task<bool> PostData()
{
// previous code
return await this.JsonResponseAsync(new { error = "Invalid Product" });
// new code
return await HttpContext.JsonResponseAsync(new { error = "Invalid Product" });
// or using the new virtual methods
return await Ok(new { error = "Invalid Product" });
}Add Items to IHttpContext
Improvements to StaticFileModule
Smaller EmbedIO
Remove the WebSocket client and fix several issues.
HTTPS Support
HTTPS Support
IPv6 Support
- Support to IPv6 (Issue #214)
You can setup IPv6 in two ways:
Using new EndPointManager.UseIpv6 will set IPAddress.IPv6Any for * hostname:
EndPointManager.UseIpv6 = true;
var instance = new WebServer("http://*:8877");
Or directly using the IPv6 address like the lookback:
var instance = new WebServer("http://[::1]:8877");
- Fix WebSocket client for targets NET47 and NETCOREAPP21
- Remove
Task.Delayfrom polling (Issue #155) - Add
ConfigureAwait(false)to async invocations.
New EmbedIO 2.0
Breaking changes
WebApiControlleris renewed. Reduce the methods overhead removing the WebServer and Context arguments. See examples below.RoutingStrategy.Regexis the default routing scheme.
Additional changes
IHttpListeneris runtime/platform independent, you can choose UnosquareHttpListenerimplementation with NET47 or NETSTANDARD20. This separation of implementations brings new access to interfaces from common Http objects likeIHttpRequest,IHttpContextand more.IWebServeris a new interface to create custom web server implementation, like a Test Web Server where all the operations are in-memory to speed up unit testing. Similar to TestServer from OWIN- General improvements in how the Unosquare
HttpListneris working and code clean-up.
Note - We encourage to upgrade to the newest EmbedIO version. Branch version 1.X will no longer be maintained, and issues will be tested against 2.X and resolved just there.