Liking cljdoc? Tell your friends :D

API

fierycod.holy-lambda.core

Shared functionality between all supported backends.

Available macros

  • entrypoint [vector-of-lambdas-var, & opts]

    Documentation

    Generates the -main function, which is an entrypoint for bootstrap script. Lambdas passed as a first parameter are converted to a routing map {HANDLER_NAME -> HANDLER_FN}.

    Routing is persisted in static PRVL_ROUTES var that is later used via a AWS Lambda Custom runtime to match the HANDLER_NAME with a corresponding HANDLER_FN.

    1. The -main might be then launched on AWS Lambda.

    2. The -main might be used to generate the native-configuration necessary to compile the project to native (native backend).

      For more info take a look into the corresponding links:

      1. https://github.com/oracle/graal/issues/1367
      2. https://github.com/oracle/graal/blob/master/substratevm/CONFIGURE.md
      3. https://github.com/oracle/graal/blob/master/substratevm/REFLECTION.md

      According to the comment of the @cstancu with the help of the agent we can find the majority of the reflective calls and generate the configuration.

      Generated configuration might then be used by native-image tool.

    Opts

    • init-hook - Side effect function with no arguments that is run before the runtime loop starts. Useful for initialization of the outer state.
    • disable-analytics? - Boolean for disabling the basic information (Runtime + Java version) send via UserAgent header AWS API.

    Usage:

    (ns some-ns
      (:require
        [fierycod.holy-lambda.core :as h]))
    
    (defn ExampleLambda1
      [request]
      (hr/text "Hello world!"))
    
    (defn ExampleLambda2
      [request]
      (hr/text "Hello world v2!"))
    
    (h/entrypoint [#'ExampleLambda1 #'ExampleLambda2])
    

fierycod.holy-lambda.agent

Provides utilities for generating resources/native-configuration via GraalVM agent.

GraalVM agent is convenient tool for complex project, so that user does not have to put each entry of reflective call to configuration by hand.

Available macros

Executes body in safe GraalVM agent context for native configurations generation. Useful when it's hard for agent payloads to cover all logic branches.

See here for more information.

In order to generate native-configuration run:

bb hl:native:conf

Usage:

(agent/in-context
  (println "Something")
  (another-body-that-should-be-inspected-via-graalvm-agent))

You can safely leave agent-context calls in the code. Agent context not set results in no code being generated by macro.

fierycod.holy-lambda.response

Provides a helpers for generating valid HL responses.

Available functions

  • redirect [url & [status]] - Redirects to the provided URL.
  • png-image [base64-str] - Creates a png image out of base64 encoded string.
  • created [url & [body]] - Returns a response for a HTTP 201 created response.
  • bad-request [body] - Returns a 400 bad request response.
  • not-found [body] - Returns a 404 not found response.
  • response [body] - Returns a skeletal response with the given body, status of 200, and no headers.
  • json [body] - Returns a skeletal response with the given body, status of 200, and content-type set to application/json.
  • text [body] - Returns a skeletal response with the given msg, status of 200, and content-type set to text/plain.
  • html [body] - Returns a skeletal response with the given body, status of 200, and content-type set to text/html.
  • edn [body] - Returns a skeletal response with the given body, status of 200, and content-type set to application/edn.
  • html [status] [resp status] - Returns an updated response with the given status..
  • header [resp name v] - Returns an updated response with the specified header added.
  • content-type [resp ctype] - Returns an updated response with the a content-type header corresponding to the given content-type.
  • find-header [resp header-name] - Looks up a header in a response (or request) case insensitively, returning the header map entry, or nil if not present.
  • get-header [resp header-name] - Looks up a header in a response (or request) case insensitively, returning the value of the header, or nil if not present.
  • update-header [resp header f & args] - Looks up a header in a response (or request) case insensitively, then updates the header with the supplied function and arguments in the manner of update-in.
  • charset [resp acharset] - Returns an updated response with the supplied charset added to the content-type header.
  • cookie [k v {:domain, expires}] - Creates a cookie string representation
  • set-cookie [resp {:k, :v}] - Sets a cookie on the response.
  • origin [resp origin-url] - Sets access-control-allow-origin header
  • credentials [resp creds] - "Sets access-control-allow-credentials header"

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close