/misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Primary LanguageErlangOtherNOASSERTION

MISULTIN

Misultin is an HTTP(S) library which can easily be embedded in your own application.

https://github.com/ostinelli/misultin

>-|-|-(°>

Features

  • Very fast
  • HTTP and HTTPS
  • Supports multiple Websocket protocols (draft-hixie-68, draft-hixie-76, draft-hybi-10 and draft-hybi-17)
  • Cookies
  • Session Variables
  • Allows for Chunked and Byte streaming responses
  • Allows for streaming file upload (via Chunked Encoding)
  • Can serves static files from a static directory (though in production you should consider a specific server such as nginx to do so)
  • Has Many customization options (maximum allowed connections, maximum body size, ...)
  • Has a callback function for your logging needs
  • Supports Unicode
  • Can start multiple servers on a single node
  • Can be used with or without Parametrized Modules
  • Can traps the client closing a browser in Comet applications
  • It's very easy to use

Quick Start

The typical 'Hello World" example code is:

-module(misultin_hello_world).
-export([start/0, stop/0]).

% start misultin http server
start() ->
    misultin:start_link([{port, 8080}, {loop, fun(Req) -> handle_http(Req) end}]).

% stop misultin
stop() ->
    misultin:stop().

% callback on request received
handle_http(Req) ->
    Req:ok("Hello World.").

Issuing the start/0 command will start an HTTP server on port 8080, which will respond to every request with an "Hello World" text.

Examples

Misultin comes packed with examples.

Simple Examples

Websockets

Comets

More Advanced

Module Exports

The complete list of module exports can be found here.

Parametrized modules

Some developers hate them, some love them. Misultin allows you to choose if you want to use them or not. The same Hello World example shown here above, but without parametrized modules, looks like this:

-module(misultin_hello_world).
-export([start/0, stop/0]).

% start misultin http server
start() ->
    misultin:start_link([{port, 8080}, {loop, fun(Req) -> handle_http(Req) end}]).

% stop misultin
stop() ->
    misultin:stop().

% callback on request received
handle_http(Req) ->
    misultin_req:ok("Hello World.", Req).

Dependencies

You will need:

Under the hood

Misultin is built using the OTP principles. When you start it using the misultin:start_link/1 command, you are actually starting a supervisor which handles all of Misultin's servers and modules.

Therefore, in real life applications you should always embed it in your own application. An easy example on how this can be done can be found in the Application Example here.

SSL Notes

If you are running misultin behind an SSL terminator such as stunnel or stud, and are using websockets, to make the websocket handshakes work, set in the starting options:

{ws_force_ssl, true} 

If you are using stunnel to terminate, to make misultin expect a PROXY.. line as per the proxy protocol you can also set in the starting options:

{proxy_protocol, true}

Newer versions of stunnel support this with the "protocol = proxy" config option.