3 Star 0 Fork 0

海峡人力云_外包/yh-public-cowboy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
plugins.mk 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
lizhijun 提交于 2020-06-28 12:03 . 源码
# 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) ->
{<<"<html><body>This is REST!</body></html>">>, 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tmsbmall_1/yh-public-cowboy.git
git@gitee.com:tmsbmall_1/yh-public-cowboy.git
tmsbmall_1
yh-public-cowboy
yh-public-cowboy
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385