Building Embedded Web Servers with Cowboy

Cowboy is a small, fast, modular HTTP server written in Erlang and available from https://github.com/extend/cowboy. It is supported by a company called Nine Nines.[41]

Cowboy is suitable for building embedded applications. There are no configuration files, and it produces no logs. Everything is controlled from Erlang.

We’ll make a very simple web server that is started with the command simple_web_server:start(Port). This starts a web server listening for commands on Port and whose root directory is the directory where the program was started.

The main function that starts everything is as follows:

cowboy/simple_web_server.erl
Line 1 
start(Port) ->
ok = application:start(crypto),
ok = application:start(ranch), ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.