Release 1.0 of Suave, a Web Server and Development Library for F#

| by Pierre-Luc Maheu Follow 3 Followers on Jan 27, 2016. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Suave 1.0 was recently released, bringing a new web development library to .NET. Suave packs a light, fully async web server and a semantic model to describe HTTP processing pipelines. Suave runs on multiple platforms and operating systems, including Windows, OSX, Linux, .NET and Mono. While it could be used from any .NET language, Suave combinators and types are designed to be used from F#.

The programming model of Suave is by using combinators, creating a bigger function with smaller ones. Henrik Feldt, maintainer of Suave, explains:

Combinators are higher order functions that can be composed in different ways to achieve different effects and produce HTTP responses.

Suave have combinators like OK "Hello" and notFound and many other low level HTTP constructs which give you great power to program any kind of web services. In Suave we operate over the realm of functions with type WebPart where type WebPart = HttpContext -async<HttpContext option>.

Having the type option type in there give us try success/fail semantics and the possibility of encoding different routes.

We use a function called choose that takes a list of WebParts and feeds each one consecutively an HttpContext until one of the WebParts returns Some httpContext; inside the httpContext is encoded the response the server will sent to the HTTP client.

We also use an operator >=> to compose WebParts and encode routings.

The example below shows the classic "Hello World!" with Suave. This web application responds to all requests it receives with "Hello World!".

open Suave
startWebServer defaultConfig (Successful.OK "Hello World!")

The next example shows how to match routes and return a 404 if none of the routes matches:

let app : WebApp =
     path "/foo" >=> OK "foo"
     path "/bar" >=> OK "bar"
     notFound "no handlers found."
startWebServer defaultConfig app

Suave is an open source project, available on GitHub. Documentation and examples are shown on Suave's official website. InfoQ also has a more extensive interview with Henrik Feldt, where he explains into more details what is Suave and how to use it.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you