-
Notifications
You must be signed in to change notification settings - Fork 178
Upgrade from v2
- The assembly name is now
EmbedIO.dll
(instead ofUnosquare.Labs.EmbedIO.dll
). - The root namespace is now
EmbedIO
(instead ofUnosquare.Labs.EmbedIO
). - Namespaces have been reorganized: instead of a code-type-based approach (
Constants
,Modules
, etc.) now they follow a more common feature-based approach. For example you will find classWebApiModule
, together with its support types, in namespaceEmbedIO.WebApi
(previously it was inUnosquare.Labs.EmbedIO.Modules
).
Gone are RegisterModule
and Module<T>()
: the preferred method of initialization is via fluent extension methods. Although there are plenty of them, they have consistent syntax and semantics, so they can be grasped in a few minutes. While we prepare more extensive documentation, you can find them here.
Wildcard routing strategy has been removed: routing is Regex-based everywhere.
HTTP context handlers do not return bool
any longer; instead, they are void functions (Sub
s, if you speak VB). Whether a HTTP context gets passed along to further modules is decided, by default, on a module-per-module basis, via the IWebModule.IsFinalHandler
property; this default may be overridden by a handler, either by calling context.SetHandled()
to stop futher processing, or with throw RequestHandler.PassThrough();
to skip the currently executing handler and pass the context along to subsequent modules.
Web API controller methods can now be void
(or return Task
) too.
A response with a status code different from 200 OK
may be generated by throwing a HTTP exception (e.g. throw HttpException.Unauthorized();
, throw HttpException.Redirect("/");
, etc. - find them all here).
If a controller method returns a value or a Task<TResult>
, the result is serialized and sent as response body.
BEWARE: Existing controller methods returning bool
will generate JSON responses containing their serialized return value, as JSON is the default response serializer for web API modules.
No more StaticFilesModule
and ResourceFilesModule
: the new FileModule
(in namespace EmbedIO.Files
, of course) uses an IFileProvider
interface to abstract the file system and provides the same level of functionality (compression, caching, support for range requests) regardless of the underlying storage. File providers are available for static files, embedded resources, and (new!) ZIP files.
FallbackModule
functionality has been split between ActionModule
and RedirectModule
. As you've probably guessed, their namespace is EmbedIO.Actions
.
Support types for unit testing have been moved to their own assembly EmbedIO.Testing.dll
.