Endpoints

Endpoints are the fundamental units of work for your applications, encapsulating the logic called from the client. Below is the editing panel for an endpoint.

Each of the properties of the endpoint are described in more detail below:

  • Name - A friendly name for you to keep your applications organized

  • Description - To serve as a place for some documentation about your application.

  • Slug - Helps to tell HTMX what endpoint to use.

  • HTTP Method - Specifies which HTTP method the endpoint should listen for to establish a match.

  • Security Mode - This crucial setting defines who can access the endpoint. The options are:

    • Execute: This setting checks the Execute verb for this specific endpoint to determine if the CurrentPerson is permitted to run it.

    • Application View|Edit|Administrate: In this mode, we refer to the Application's Execute settings to decide if the endpoint can be edited. This creates a simple, application-wide pattern, reducing administrative overhead.

  • Code Template - If you can't guess what goes here, perhaps reconsider your career in Lava Application Building...😀 The application's configuration rigging is available to your Lava using the 'ConfigurationRigging' merge field.

  • Enabled Lava Commands - This setting determines which Lava commands to make available to your template.

  • Caching Settings - The caching settings specify how CDNs and local browsers are permitted to cache the response from your endpoint.

Calling The Endpoint

The full route to the endpoint is:

/api/lava-app/v1/{application-slug}/{endpoint-slug}

We've simplified this though when using the Lava Application Content block. Appending a ^ allows you to just use the application and endpoint slug.

^/{application-slug}/{endpoint-slug}

HTTP Methods

You might wonder when to use which HTTP method. Generally, the choice of method doesn’t significantly impact operations, but it's crucial to avoid using the GET method for editing database data, as GET requests can be less secure and easily initiated by third-party links. Typically, the following patterns are observed:

  • GET - Used to retrieve data for display.

  • POST - This is the general purpose method for writing data to the database. Many people use this for create new resources.

  • PUT - Commonly used for replacing an existing resource with an updated version.

  • DELETE - Used for removing data from the database.

Lava for Endpoints

When writing Lava for your endpoints you have access to the following merge fields:

  • Url - The URL as an array of it's various parts.

  • RawUrl - The URL as a single string.

  • Method - The HTTP verb that was used for the request.

  • QueryString - A dictionary of the various query string parameters. Example: {% assign articleId = QueryString.articleId %}

  • RemoteAddress - The IP address of the remote client.

  • RemoteName - The hostname of the remote client.

  • ServerName - The server's host name.

  • Form - Dictionary of values of form elements posted to the HTTP request body, with a form using the POST method.

Last updated