erf (erf v0.2.0)
View Sourceerf is a library that provides a design-first framework to build RESTful APIs in Erlang.
Summary
Functions
Returns the router for an instance of the server.
Reloads the configuration for an instance of the server.
Starts the supervision tree for an instance of the server.
Stops the supervision tree for an instance of the server.
Types
-type api() :: erf_parser:api().
-type body() :: undefined | json:decode_value().
-type conf() :: #{spec_path := binary(), callback := module(), port => inet:port_number(), name => atom(), spec_parser => module(), preprocess_middlewares => [module()], postprocess_middlewares => [module()], ssl => boolean(), certfile => binary(), keyfile => binary(), static_routes => [static_route()], swagger_ui => boolean(), log_level => logger:level()}.
-type method() :: get | post | put | delete | patch | head | options | trace | connect.
-type request() :: #{scheme := undefined | binary(), host := undefined | binary(), port := undefined | 1..65535, path := [binary()], path_parameters => [path_parameter()], method := method(), query_parameters := [query_parameter()], headers := [header()], body := body(), peer := undefined | binary(), route := binary(), context => any()}.
-type response() :: {StatusCode :: pos_integer(), Headers :: [header()], Body :: body() | {file, binary()} | stream_body()}.
-type send_chunk_fun() :: fun((iodata()) -> ok | {error, closed | timeout}).
-type static_dir() :: {dir, binary()}.
-type static_file() :: {file, binary()}.
-type static_route() :: {Path :: binary(), Resource :: static_file() | static_dir()}.
-type stream_body() :: {stream, stream_producer()}.
-type stream_producer() :: fun((send_chunk_fun()) -> any()).
Functions
-spec get_router(Name) -> Result when Name :: atom(), Result :: {ok, Router} | {error, Reason}, Router :: binary(), Reason :: term().
Returns the router for an instance of the server.
-spec reload_conf(Name, Conf) -> Result when Name :: atom(), Conf :: erf_conf:t(), Result :: ok | {error, Reason}, Reason :: term().
Reloads the configuration for an instance of the server.
-spec start_link(Conf) -> Result when Conf :: conf(), Result :: {ok, Pid} | ignore | {error, Reason}, Pid :: pid(), Reason :: term().
Starts the supervision tree for an instance of the server.
Stops the supervision tree for an instance of the server.