[erlang-questions] HTTPS and Basic Authentication with Erlang
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
> 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
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:
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...
Size: 801 bytes
Desc: OpenPGP digital signature
More information about the erlang-questions