I am looking for the Jetty equivalent in the Net Framework world - managed code. Does it exist? I would like to use the library from an F#/C#/VB.net application. "Don't deploy your application in Jetty, deploy Jetty in your application."
Jetty provides a web server and servlet container, additionally providing support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and are freely available for commercial use and distribution.
Jetty is a Java HTTP (Web) server and Java Servlet container. Developed as a free and open source project as part of the Eclipse Foundation, Jetty is now often used for machine to machine communications, usually within larger software frameworks.
Download Jetty from https://www.eclipse.org/jetty/download.html and extract the zip file somewhere to your filesystem. This update site contains also a Eclipse p2 update site, in case you want to use Jetty in an OSGi environment.
Jetty POJO Configuration You can achieve this either by: Writing Java code to directly instantiate and assemble Jetty objects. This is referred to as Embedding Jetty. Using Jetty XML configuration, which is an Inversion of Control (IoC) framework, to instantiate and assemble Jetty objects as XML objects.
How sophisticated API are you looking for? For simple tasks, I think you can get fairly far just by using the standard HttpListener
type. There is an MSDN sample that encapsulates it with an F# agent (part 3) and then uses it to create a simple chat server (part 4).
The core part of the chat server looks fairly straightforward:
let handleRequest (context:HttpListenerContext) = async {
match context.Request.Url.LocalPath with
| "/post" ->
// Send message to the chat room
room.SendMessage(context.Request.InputString)
| "/chat" ->
// Get messages from the chat room (asynchronously!)
let! text = room.AsyncGetContent()
context.Response.Reply(text)
| s ->
// Omitted: handle file request }
A more advanced library available for F# might be Frack (An implementation of the Open Web Interface for .NET (OWIN), a .NET Web Server Gateway Interface, written in F#.) This also looks very easy to use.
ServiceStack also runs inside a self-hosted HttpListener application in Win/.NET or Mono/Linux (in addition to an ASP.NET host).
See the self-hosted wiki page for simple examples of running ServiceStack in a C# or F# Console apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With