From 49fa5aa2a127bdf8924d02bf77e5086b39c7a447 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 3 Sep 2025 21:15:36 -0400 Subject: i vibe coded it --- server/_build/default/lib/cowboy/plugins.mk | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 server/_build/default/lib/cowboy/plugins.mk (limited to 'server/_build/default/lib/cowboy/plugins.mk') diff --git a/server/_build/default/lib/cowboy/plugins.mk b/server/_build/default/lib/cowboy/plugins.mk new file mode 100644 index 0000000..3fb2f7e --- /dev/null +++ b/server/_build/default/lib/cowboy/plugins.mk @@ -0,0 +1,75 @@ +# See LICENSE for licensing information. + +# Plain HTTP handlers. +define tpl_cowboy.http +-module($(n)). +-behavior(cowboy_handler). + +-export([init/2]). + +init(Req, State) -> + {ok, Req, State}. +endef + +# Loop handlers. +define tpl_cowboy.loop +-module($(n)). +-behavior(cowboy_loop). + +-export([init/2]). +-export([info/3]). + +init(Req, State) -> + {cowboy_loop, Req, State, hibernate}. + +info(_Info, Req, State) -> + {ok, Req, State, hibernate}. +endef + +# REST handlers. +define tpl_cowboy.rest +-module($(n)). +-behavior(cowboy_rest). + +-export([init/2]). +-export([content_types_provided/2]). +-export([to_html/2]). + +init(Req, State) -> + {cowboy_rest, Req, State}. + +content_types_provided(Req, State) -> + {[ + {{<<"text">>, <<"html">>, '*'}, to_html} + ], Req, State}. + +to_html(Req, State) -> + {<<"This is REST!">>, Req, State}. +endef + +# Websocket handlers. +define tpl_cowboy.ws +-module($(n)). +-behavior(cowboy_websocket). + +-export([init/2]). +-export([websocket_init/1]). +-export([websocket_handle/2]). +-export([websocket_info/2]). + +init(Req, State) -> + {cowboy_websocket, Req, State}. + +websocket_init(State) -> + {[], State}. + +websocket_handle({text, Data}, State) -> + {[{text, Data}], State}; +websocket_handle({binary, Data}, State) -> + {[{binary, Data}], State}; +websocket_handle(_Frame, State) -> + {[], State}. + +websocket_info(_Info, State) -> + {[], State}. +endef -- cgit v1.2.3