v0.32 – OWIN, basicAuth, headers
We're proud to present the v0.32 release with OWIN support. The OWIN support has been coming for a while now, almost a year in the making, but finally it's there.
pathStarts
We've added a combinator that checks if the absolute path of the request uri starts with some string: val Applicatives.pathStarts : (prefix:string) -> WebPart
.
OWIN
This is the first OWIN release which has been tested with NancyFx and WebSharper, but not so much with middleware from the C# landscape, so there's most likely place for improvements. For those interested, here's where the sausage is made.
It's planned to add better support for IPrincipal
/ IClaimsPrincipal
, but it's not been decided what the API should look like yet. Also, we plan to make the current memory buffering of the OWIN response optional; the reason we do it is because you may want to compose WebPart
s after the OWIN app.
We're maintaining composability of your apps by doing it, but it means you probably don't want to serve extremely large files through the OWIN layer unless you have a memory of (size * concurrent users) on your server. However, consider that ASP.Net buffered responses for a decade and most people were happily oblivious to it.
That said, we're considering adding a ofAppTerminating
hoisting function that clearly states it may terminate the Suave applicative pipeline.
In this release, Suave is the OWIN server and host and not app, as the web parts currently are fairly specific to our HttpResult type. If you want to use the Suave applicatives this way, we'd be interested to know.
That Suave now is a valid OWIN host, means you should be able to run ASP.Net vNext on the server, if they have followed the OWIN specification. You now have another high-performance, web server to use on Linux and Windows to host corporation-lawyer sanctioned software on top.
The F# community is absolutely on-board with the change; read WebSharper's Suave announcement to see how you can easily make server-rendered HTML and JS without leaving F#.
Thanks to @haf @panesofglass for their work on this feature and to everyone who has tested and contributed to the discussion!
Basic Authentication
This is a Breaking change, as the signature now looks like this:
module Authentication =
val authenticateBasic : f:(string * string -> bool) -> protectedPart:WebPart -> WebPart
It now matches the rest of Suave and lets you have access inside protectedPart
, to the username of the user who successfully authenticated.
Thanks to @xkrt for his work on this feature!
Headers
We've changed the semantics of setHeader
to overwrite existing headers with identical keys to what was set. This means it's probably working more like you expect (from the name, from the mental model of the http resonse).
addHeader
is the one to use if you want to add and not overwrite a header.
module Headers =
/// Ensures that the key header has the given value
val setHeader : key:string -> value:string -> WebPart
/// Adds the header key with the given value to the list of returned headers, even if that header already exists
val addHeader : key:string -> value:string -> WebPart
Thanks to @xkrt for his work on this feature!
Upcoming improvements
@ademar has been auspicated the tea-leafs and saw that was libuv is good. Thus, as they say; once auspicated, almost done! #306
This means the suave is even less dependent on a the niche .Net feature of "async socket event args" and more in line with what's rapidly becoming the go-to (without the "considered harmful") asynchronous socket library for Linux (and Windows). After all, nodejs runs on AIX. I leave you all to consider the unicorn+rainbow implications of this.
We're also happy to thoughtfully consider that these changes have had absolutely no benefit to performance, nor drag on performance, come to think about it, so Suave is still a really fast and cross platform async web server!
// Henrik & Ademar