[erlang-questions] HTTPS and Basic Authentication with Erlang

Kenneth Lakin <>
Thu Feb 16 02:34:04 CET 2017


On 02/15/2017 12:37 AM, David Wright wrote:
> However I would like to write a restful API and decode the URL and
obtain parameters
> for the API method.

AFAIK, the "magic" of REST is behaving in a vaguely-standard way to
requests containing particular METHODs at particular paths.

You can write your own Erlang httpd callback modules, and -AFAICT- get
access to just about everything you'd need to know about the HTTP(S)
request using the tools provided.

<http://erlang.org/doc/man/httpd.html#Module:do-1> describes the
mandatory function that a httpd callback module must implement.
Searching for "Erlang Web Server API Modules" in that page tells you
about how to make httpd call your module when a request comes in.
Searching for "ERLANG WEB SERVER API DATA TYPES" tells you how to load
the relevant record definition into your callback module, which will
give you easy access to the request's METHOD and more.
<http://erlang.org/doc/man/httpd_util.html> looks like it has some
useful tools for working with HTTP requests.
<http://erlang.org/doc/man/http_uri.html> looks like it has useful URI
processing code.

If you're dead-set on not using Cowboy, spend some time with the
relevant parts of the inets documentation. The relevant parts of the
inets User's Guide might also be informative:
<http://erlang.org/doc/apps/inets/http_server.html>.

It's kind of important to note that both Cowboy and the HTTP server that
ships with Erlang/OTP are "just" a set of modules written in Erlang.
Unless you're operating in an environment where it's a pain to load
anything that doesn't ship with Erlang/OTP, don't let the fact that an
application doesn't ship with Erlang/OTP stop you from considering it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170215/eab397d4/attachment.bin>


More information about the erlang-questions mailing list