Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/nova_plugin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,20 @@
{reply, Status :: integer(), Body :: binary()} |
{reply, Status :: integer(), Headers :: [{binary(), binary()}], Body :: binary()}.

%% @doc
%% Start function for the plugin. This function is called when the plugin is started
%% and will return a state that will be passed to the other functions during
%% the life cycle of the plugin. The state can be any term.
%% @end
-callback init() -> State :: nova:state().
-optional_callbacks([init/0]).

%% @doc
%% Stop function for the plugin. This function is called when the application is stopped.
%% It takes a state as argument and should return ok.
%% @end
-callback stop(State :: nova:state()) -> ok.
-optional_callbacks([stop/1]).

%% @doc
%% This function is called before the request is processed. It can modify the request
%% and the nova-state. It takes a state and a map of options as arguments and should return
%% either {ok, NewState}, {break, NewState}, {stop, NewState} or {error, Reason}.
%% @end
-callback pre_request(Req :: cowboy_req:req(), Env :: any(),
Options :: map(), PluginState :: any()) ->
{ok, Req0 :: cowboy_req:req(), NewState :: any()} |
Expand All @@ -65,12 +59,10 @@
{error, Reason :: term()}.
-optional_callbacks([pre_request/4]).

%% @doc
%% This function is called after the request is processed. It can modify the request.
%% It takes a state and a map of options as arguments and should return
%% either {ok, NewState}, {break, NewState}, {stop, NewState} or {error, Reason}.
%% The state is only used if there's another plugin invoked after this one.
%% @end
-callback post_request(Req :: cowboy_req:req(), Env :: any(),
Options :: map(), PluginState :: any()) ->
{ok, Req0 :: cowboy_req:req(), NewState :: any()} |
Expand All @@ -82,10 +74,8 @@
{error, Reason :: term()}.
-optional_callbacks([post_request/4]).

%% @doc
%% This function should return information about the plugin. The information is used
%% in the documentation and in the plugin-listing.
%% @end
-callback plugin_info() -> #{title := binary(),
version := binary(),
url := binary(),
Expand Down