mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Add the remaining missing specs
Found thanks to warn_missing_spec and added with the help of typer. Eunit functions do not have specs yet however.
This commit is contained in:
parent
227529761c
commit
58267689f0
4 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
{cover_enabled, true}.
|
{cover_enabled, true}.
|
||||||
{erl_opts, [
|
{erl_opts, [
|
||||||
%% bin_opt_info,
|
%% bin_opt_info,
|
||||||
|
%% warn_missing_spec,
|
||||||
warnings_as_errors,
|
warnings_as_errors,
|
||||||
warn_export_all
|
warn_export_all
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -60,6 +60,7 @@ rfc1123() ->
|
||||||
|
|
||||||
%% gen_server.
|
%% gen_server.
|
||||||
|
|
||||||
|
-spec init([]) -> {ok, #state{}}.
|
||||||
init([]) ->
|
init([]) ->
|
||||||
?TABLE = ets:new(?TABLE, [set, protected,
|
?TABLE = ets:new(?TABLE, [set, protected,
|
||||||
named_table, {read_concurrency, true}]),
|
named_table, {read_concurrency, true}]),
|
||||||
|
@ -69,28 +70,32 @@ init([]) ->
|
||||||
ets:insert(?TABLE, {rfc1123, B}),
|
ets:insert(?TABLE, {rfc1123, B}),
|
||||||
{ok, #state{universaltime=T, rfc1123=B, tref=TRef}}.
|
{ok, #state{universaltime=T, rfc1123=B, tref=TRef}}.
|
||||||
|
|
||||||
|
-spec handle_call(_, _, State)
|
||||||
|
-> {reply, ignored, State} | {stop, normal, stopped, State}.
|
||||||
handle_call(stop, _From, State=#state{tref=TRef}) ->
|
handle_call(stop, _From, State=#state{tref=TRef}) ->
|
||||||
{ok, cancel} = timer:cancel(TRef),
|
{ok, cancel} = timer:cancel(TRef),
|
||||||
{stop, normal, stopped, State};
|
{stop, normal, stopped, State};
|
||||||
|
|
||||||
handle_call(_Request, _From, State) ->
|
handle_call(_Request, _From, State) ->
|
||||||
{reply, ignored, State}.
|
{reply, ignored, State}.
|
||||||
|
|
||||||
|
-spec handle_cast(_, State) -> {noreply, State}.
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
-spec handle_info(_, State) -> {noreply, State}.
|
||||||
handle_info(update, #state{universaltime=Prev, rfc1123=B1, tref=TRef}) ->
|
handle_info(update, #state{universaltime=Prev, rfc1123=B1, tref=TRef}) ->
|
||||||
T = erlang:universaltime(),
|
T = erlang:universaltime(),
|
||||||
B2 = update_rfc1123(B1, Prev, T),
|
B2 = update_rfc1123(B1, Prev, T),
|
||||||
ets:insert(?TABLE, {rfc1123, B2}),
|
ets:insert(?TABLE, {rfc1123, B2}),
|
||||||
{noreply, #state{universaltime=T, rfc1123=B2, tref=TRef}};
|
{noreply, #state{universaltime=T, rfc1123=B2, tref=TRef}};
|
||||||
|
|
||||||
handle_info(_Info, State) ->
|
handle_info(_Info, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
-spec terminate(_, _) -> ok.
|
||||||
terminate(_Reason, _State) ->
|
terminate(_Reason, _State) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
-spec code_change(_, State, _) -> {ok, State}.
|
||||||
code_change(_OldVsn, State, _Extra) ->
|
code_change(_OldVsn, State, _Extra) ->
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
-module(cowboy_http_handler).
|
-module(cowboy_http_handler).
|
||||||
-export([behaviour_info/1]).
|
-export([behaviour_info/1]).
|
||||||
|
|
||||||
|
-spec behaviour_info(_)
|
||||||
|
-> undefined | [{handle, 2} | {init, 3} | {terminate, 2}, ...].
|
||||||
behaviour_info(callbacks) ->
|
behaviour_info(callbacks) ->
|
||||||
[{init, 3}, {handle, 2}, {terminate, 2}];
|
[{init, 3}, {handle, 2}, {terminate, 2}];
|
||||||
behaviour_info(_Other) ->
|
behaviour_info(_Other) ->
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
-module(cowboy_http_websocket_handler).
|
-module(cowboy_http_websocket_handler).
|
||||||
-export([behaviour_info/1]).
|
-export([behaviour_info/1]).
|
||||||
|
|
||||||
|
-spec behaviour_info(_) -> undefined | [{websocket_handle, 3}
|
||||||
|
| {websocket_init, 3} | {websocket_terminate, 3}, ...].
|
||||||
behaviour_info(callbacks) ->
|
behaviour_info(callbacks) ->
|
||||||
[{websocket_init, 3}, {websocket_handle, 3}, {websocket_terminate, 3}];
|
[{websocket_init, 3}, {websocket_handle, 3}, {websocket_terminate, 3}];
|
||||||
behaviour_info(_Other) ->
|
behaviour_info(_Other) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue