Skip to content

Instantly share code, notes, and snippets.

Loïc Hoguin essen

Block or report user

Report or block essen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cowboy_req.asciidoc



cowboy_req - HTTP request and response


The module cowboy_req provides functions to access, manipulate and respond to requests.

View ast1.erl
{p,[<<"cowboy_req:method - HTTP method">>]},
{listing,#{language => <<"erlang">>},
<<"method(Req :: cowboy_req:req()) -> Method :: binary()">>},
{p,[<<"Return the request's HTTP method.">>]},
{p,[<<"The method can also be obtained using pattern matching:">>]},
{listing,#{language => <<"erlang">>},<<"#{method := Method} = Req.">>},
View man cowboy_req.txt
cowboy_req(3) Cowboy Function Reference cowboy_req(3)
cowboy_req - HTTP request and response
The module cowboy_req provides functions to access, manipulate and
respond to requests.
There are four types of functions in this module. They can be differ‐
cowboy:start_clear - Listen for connections using plain TCP
start_clear(Name :: ranch:ref(),
NumAcceptors :: non_neg_integer(),
TransportOpts :: ranch_tcp:opts(),
ProtocolOpts :: opts())
essen / fw_resource.erl
Last active Sep 17, 2016
Thoughts on callback interface for describing resources in an hypermedia framework
View fw_resource.erl
-type resource() :: module().
-type uri() :: string().
-type relation() :: index | self | ...
-type action() :: fetch | stream | create | replace | append | process | delete | patch | atom().
-type media_type() :: atom().
-type internal_representation() :: any().
-type request() :: ...
View Makefile
$(verbose) for dep in $(ALL_APPS_DIRS) ; do \
mkdir -p $$dep/ebin; \
$(verbose) for dep in $(ALL_APPS_DIRS) ; do \
$(MAKE) -C $$dep IS_APP=1 || exit $$?; \
View versioning.asciidoc

A common concern with REST APIs is how do you version them? The answer is often something like put the version in the beginning of the URI path. But that’s a terrible advice. This prevents you to make small updates to your API, because you need to duplicate everything every time you increase the version.

A good way to version an API is to not do it. Instead, you can version the media types.

View map_req.erl
init(#{method := <<"GET">>} = Req, State) ->
cowboy_req:reply(204, Req),
{ok, Req, State}.
essen / my_module.erl
Created Oct 14, 2013
Thinking in Erlang: The Code
View my_module.erl
-export([my_function/1, my_function/2]).
-export([infinite_loop/0, f/1, r/2, sort/1]).
-export([only_primes/1, is_prime/1]).
my_function(A) when is_integer(A) ->
my_function(A, 0);
my_function(A) when is_list(A) ->
my_function(list_to_integer(A), 0).

List of databases we may be looking to support

  • MariaDB
  • Microsoft SQL Server
  • MySQL
  • Oracle Database
  • PostgreSQL
  • SQLite
  • VoltDB
You can’t perform that action at this time.