erf_conf (erf v0.1.2)

View Source
erf's configuration manager module.

Summary

Types

t/0

-type t() ::
          #{callback => module(),
            log_level => logger:level(),
            preprocess_middlewares => [module()],
            postprocess_middlewares => [module()],
            route_patterns => erf:route_patterns(),
            router => erl_syntax:syntaxTree(),
            router_mod => module(),
            spec_path => binary(),
            spec_parser => module(),
            static_routes => [erf:static_route()],
            swagger_ui => boolean()}.

Functions

clear(Name)

-spec clear(Name) -> Result when Name :: atom(), Result :: ok.
Clears the configuration for the given Name.

get(Name)

-spec get(Name) -> Result when Name :: atom(), Result :: {ok, Conf} | {error, not_found}, Conf :: t().
Returns the configuration for the given Name.

log_level(Name)

-spec log_level(Name) -> Result
                   when
                       Name :: atom(),
                       Result :: {ok, LogLevel} | {error, not_found},
                       LogLevel :: logger:level().
Returns the log level for the given Name.

postprocess_middlewares(Name)

-spec postprocess_middlewares(Name) -> Result
                                 when
                                     Name :: atom(),
                                     Result :: {ok, PostprocessMiddlewares} | {error, not_found},
                                     PostprocessMiddlewares :: [module()].
Returns the postprocess middlewares for the given Name.

preprocess_middlewares(Name)

-spec preprocess_middlewares(Name) -> Result
                                when
                                    Name :: atom(),
                                    Result :: {ok, PreprocessMiddlewares} | {error, not_found},
                                    PreprocessMiddlewares :: [module()].
Returns the preprocess middlewares for the given Name.

route_patterns(Name)

-spec route_patterns(Name) -> Result
                        when
                            Name :: atom(),
                            Result :: {ok, RoutePatterns} | {error, not_found},
                            RoutePatterns :: erf:route_patterns().
Returns a mapping between the routes and their matching RegEx for a given Name.

router(Name)

-spec router(Name) -> Result
                when
                    Name :: atom(),
                    Result :: {ok, Router} | {error, not_found},
                    Router :: erl_syntax:syntaxTree().
Returns the router for the given Name.

router_mod(Name)

-spec router_mod(Name) -> Result
                    when
                        Name :: atom(),
                        Result :: {ok, RouterMod} | {error, not_found},
                        RouterMod :: module().
Returns the router module name for the given Name.

set(Name, Conf)

-spec set(Name, Conf) -> Result when Name :: atom(), Conf :: t(), Result :: ok.
Sets the configuration for the given Name.