-module(helloworld). -export([ init/1 , routes/0]). -behaviour(http_handler). -include("./include/brunhilde.hrl"). -include_lib("xmerl/include/xmerl.hrl"). %% Called upon the start of the server, server %% can do whatever it wishes do to here. -spec init(atom()) -> atom(). init(InstanceName) -> ?liof("I have been initialized, I am ~p~n", [InstanceName]), ok. routes() -> [ #route{protocol = json, verb = get, address = "/helloworld/hello/", callback = fun handle_hello/4} , #route{protocol = json, verb = get, address = "/error", callback = fun handle_error/4} , #route{protocol = html, verb = get, address = "/helloworld.html", callback = fun handle_html/4} , #route{protocol = html, verb = get, address = "/helloworld2.html", callback = fun handle_html2/4} , #route{protocol = xml, verb = get, address = "/helloworld/xml/", callback = fun handle_xml/4} , #route{protocol = file, verb = get, address = "/helloworld/brunhilde.jpg", callback = fun handle_pic/4} , #route{protocol = html, verb = get, address = "/helloworld/template", callback = fun handle_template/4} , #route{protocol = html, verb = get, address = "/setcookie", callback = fun set_cookie/4} , #route{protocol = html, verb = get, address = "/hascookie", callback = fun has_cookie/4} , #route{protocol = file, verb = get, address = "/favicon.ico", callback = fun handle_icon/4} , {'*', fun handle_wildcard/4}]. handle_hello(_Data, Parameters, _Headers, _InstanceName) -> io:format("Someone asked for ~p", [Parameters]), #{<<"hello">> => <<"hello2u">>}. handle_error(_Data, _Parameters, _Headers, _InstanceName) -> io:format("some error!"), #{<<"hello">> => <<"error">>}. handle_html(_Data, _Parameters, _Headers, _InstanceName) -> Html = "" "
" "
"
"