(api {:keys [transit-params parser env] :as req})
The /api Request handler. The incoming request will have a database connection, parser, and error handler already injected. This function should be fairly static, in that it calls the parser, and if the parser does not throw and exception it wraps the return value in a transit response. If the parser throws an exception, then it calls the injected error handler with the request and the exception. Thus, you can define the handling of all API requests via system injection at startup.
The /api Request handler. The incoming request will have a database connection, parser, and error handler already injected. This function should be fairly static, in that it calls the parser, and if the parser does not throw and exception it wraps the return value in a transit response. If the parser throws an exception, then it calls the injected error handler with the request and the exception. Thus, you can define the handling of all API requests via system injection at startup.
(build-handler api-parser injections & {:keys [extra-routes app-name]})
Build a web request handler.
Parameters:
api-parser
: A Parser that can interpret incoming API queries, and return the proper response. Return is the response when no exception is thrown.injections
: A vector of keywords to identify component dependencies. Components injected here can be made available to your parser.extra-routes
: See make-fulcro-server
app-name
: See make-fulcro-server
Build a web request handler. Parameters: - `api-parser`: A Parser that can interpret incoming API queries, and return the proper response. Return is the response when no exception is thrown. - `injections`: A vector of keywords to identify component dependencies. Components injected here can be made available to your parser. - `extra-routes`: See `make-fulcro-server` - `app-name`: See `make-fulcro-server`
(handler api-parser om-parsing-env extra-routes app-name pre-hook fallback-hook)
Create a web request handler that sends all requests through a parser. The om-parsing-env of the parses will include any components that were injected into the handler.
Returns a function that handles requests.
Create a web request handler that sends all requests through a parser. The om-parsing-env of the parses will include any components that were injected into the handler. Returns a function that handles requests.
(get-fallback-hook this)
Gets the current fallback-hook handler.
Gets the current fallback-hook handler.
(get-pre-hook this)
Gets the current pre-hook handler.
Gets the current pre-hook handler.
(set-fallback-hook! this fallback-hook)
Sets the fallback handler in case nothing else returned.
Sets the fallback handler in case nothing else returned.
(set-pre-hook! this pre-hook)
Sets the handler before any important handlers are run.
Sets the handler before any important handlers are run.
(make-fulcro-server
&
{:keys [app-name parser parser-injections config-path components extra-routes]
:or {config-path "/usr/local/etc/fulcro.edn" parser (server/fulcro-parser)}
:as params})
Make a new fulcro server.
Parameters:
*config-path
OPTIONAL, a string of the path to your configuration file on disk.
The system property -Dconfig=/path/to/conf can also be passed in from the jvm.
*components
OPTIONAL, a map of Sierra component instances keyed by their desired names in the overall system component.
These additional components will merged with the fulcro-server components to compose a new system component.
*parser
OPTIONAL, an om parser function for parsing requests made of the server. To report errors, the
parser must throw an ExceptionInfo with a map with keys :status
, :headers
, and :body
.
This map will be converted into the response sent to the client. Defaults to server/fulcro-parser
*parser-injections
a vector of keywords which represent components which will be injected as the om parsing env.
*extra-routes
OPTIONAL, a map containing :routes
and :handlers
,
where routes is a bidi routing data structure,
and handlers are map from handler name to a function of type :: Env -> BidiMatch -> Res
see handler/wrap-extra-routes
& handler-spec for more.
*app-name
OPTIONAL, a string that will turn "/api" into "<app-name>/api"
Returns a Sierra system component.
Make a new fulcro server. Parameters: *`config-path` OPTIONAL, a string of the path to your configuration file on disk. The system property -Dconfig=/path/to/conf can also be passed in from the jvm. *`components` OPTIONAL, a map of Sierra component instances keyed by their desired names in the overall system component. These additional components will merged with the fulcro-server components to compose a new system component. *`parser` OPTIONAL, an om parser function for parsing requests made of the server. To report errors, the parser must throw an ExceptionInfo with a map with keys `:status`, `:headers`, and `:body`. This map will be converted into the response sent to the client. Defaults to `server/fulcro-parser` *`parser-injections` a vector of keywords which represent components which will be injected as the om parsing env. *`extra-routes` OPTIONAL, a map containing `:routes` and `:handlers`, where routes is a bidi routing data structure, and handlers are map from handler name to a function of type :: Env -> BidiMatch -> Res see `handler/wrap-extra-routes` & handler-spec for more. *`app-name` OPTIONAL, a string that will turn "/api" into "<app-name>/api" Returns a Sierra system component.
(make-fulcro-test-server & {:keys [parser parser-injections components]})
Make sure to inject a :seeder component in the group of components that you pass in!
Make sure to inject a :seeder component in the group of components that you pass in!
(make-web-server & [handler])
Builds a web server with an optional argument that
specifies which component to get :middleware
from,
defaults to :handler
. This component requires that your
system has a Config component under the key :config.
Builds a web server with an optional argument that specifies which component to get `:middleware` from, defaults to `:handler`. This component requires that your system has a Config component under the key :config.
(wrap-connection handler route-handler api-parser om-parsing-env app-name)
Ring middleware function that invokes the general handler with the parser and parsing environment on the request.
Ring middleware function that invokes the general handler with the parser and parsing environment on the request.
(wrap-extra-routes dflt-handler
{:as extra-routes :keys [routes handlers]}
om-parsing-env)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close