Update Erlang/cowboy: add plain text route
@@ -3,6 +3,7 @@
"tests": [{
"default": {
"setup_file": "setup",
+ "plaintext_url": "/plaintext",
"json_url": "/json",
"db_url": "/db",
"query_url": "/query?queries=",
@@ -25,6 +25,7 @@ start(_Type, _Args) ->
emysql:prepare(db_stmt, <<"SELECT * FROM World where id = ?">>),
Dispatch = cowboy_router:compile([
{'_', [
+ {"/plaintext", plaintext_handler, []},
{"/json", json_handler, []},
{"/db", db_handler, []},
{"/query", query_handler, []}
@@ -0,0 +1,18 @@
+%% Feel free to use, reuse and abuse the code in this file.
+
+%% @doc Hello world handler.
+-module(plaintext_handler).
+-export([init/3]).
+-export([handle/2]).
+-export([terminate/3]).
+init(_Transport, Req, []) ->
+ {ok, Req, undefined}.
+handle(Req, State) ->
+ {ok, Req2} = cowboy_req:reply(200, [{<<"Content-Type">>, <<"text/plain">>}], <<"Hello, World!">>, Req),
+ {ok, Req2, State}.
+terminate(_Reason, _Req, _State) ->
+ ok.