Dynamic variables for things associated with the current HTTP request, such as current user and their permissions; current limit and offset, etc. TODO -- move stuff like | (ns metabase.request.current) |
(def ^:private ^:dynamic *request* nil) | |
Current Ring request being handled, if any. | (defn current-request [] *request*) |
Impl for [[with-current-request]]. | (defn do-with-current-request
[request thunk]
(binding [*request* request]
(thunk))) |
Execute | (defmacro with-current-request
{:style/indent :defn}
[request & body]
`(do-with-current-request ~request (^:once fn* [] ~@body))) |
(def ^:private ^:dynamic *limit* nil) | |
Limit for offset-limit paging. Automatically set by [[metabase.server.middleware.offset-paging]] server middleware. | (defn limit [] *limit*) |
(def ^:private ^:dynamic *offset* nil) | |
Offset for offset-limit paging. Automatically set by [[metabase.server.middleware.offset-paging]] server middleware. | (defn offset [] *offset*) |
(def ^:private ^:dynamic *paged?* false) | |
Whether the current request is paged or not. Automatically set by [[metabase.server.middleware.offset-paging]] server middleware. | (defn paged? [] *paged?*) |
Impl for [[with-limit-and-offset]]. | (defn do-with-limit-and-offset
[limit offset thunk]
(binding [*limit* limit
*offset* offset
*paged?* (boolean (or limit offset))]
(thunk))) |
Execute | (defmacro with-limit-and-offset
{:style/indent :defn}
[limit offset & body]
`(do-with-limit-and-offset ~limit ~offset (^:once fn* [] ~@body))) |