leptus_utils module
Table of Contents
leptus_utils module
This module provides a bunch of utilities.
Functions
priv_dir/1
Finds the path to the priv directory in an application.
priv_dir(App) -> Dir | {error, bad_name}
Types:
App = atom() Dir = file:name_all()
paginator/1
Generates a paginator function for paginating a list of elements.
paginator(NElementPerPage) -> fun((Page, Objects) -> Objects)
Types:
NElementPerPage = Page = non_neg_integer() Objects = [any()]
Example:
1> Page = paginator(3). 2> Page(2, [1,2,3,4,5,6,7,8,9]). [4,5,6]
paginate/3
Paginates a list of objects.
paginate(NElementPerPage, Objects, Page) -> Objects
Types:
NElementPerPage = Page = non_neg_integer() Objects = [any()]
listener_bucket/1
Returns a running listener bucket that includes Handlers, Options and started date-time.
listener_bucket(Listener) -> Bucket | not_found
Types:
Listener = http | https
Bucket = #listener_bucket{}
listener_handlers/1
Returns handlers of a running listener.
listener_handlers(Listener) -> Handlers | {error, not_found}
Types:
Listener = http | https
Handlers = [{module(), State :: any()}]
print_listener_info/1
Prints a running listener information, such as handlers, routes and allowed methods.
print_listener_info(Listener) -> ok
Types:
Listener = http | https