18.4.0 released Sep 25, 2023
Task param

Purpose: Get input parameter and set it as a task selector.

task-param <name>

task-param is the same as input-param, except that parameter <name> is set as a task selector, which means it can be used in a subsequent if-task to decide which task a request handler should perform. While you can do this without task-param and if-task (by simply checking a value of any input-param), if you do use it, then a given input parameter <name> has been semantically selected to be a task selector; this helps with ease of reading the code and its maintainability.

You can have any number of task-param statements execute in a request handler. Each time a different parameter <name> can be selected as a task selector, and the subsequent execution of if-task will refer to it; this allows for subtasks (see if-task). In most cases though, a single task-param is used per request handler.

Note that because task-param is set and can change at runtime, to work with if-task, it must be set prior to if-task, or if you are using set-input, then set-input must be also used prior to if-task.

The way requests and their tasks are structured is flexible and not prescribed, and may depend on a methodology used. For example, a request may refer to an entity (such as "customer") and tasks to actions taken on it (such as "add", "update" or "delete"). A request may, however, also refer to an action taken on an entity (such as "add"), and tasks may refer to an entity, such as a "customer", "item" or "order". Another option is for a request to be a combination of the two, such as "add-customer" or "update-customer" - in this case tasks may refer to aspects of these actions (such as a region/legal jurisdiction of where the customer is, subscription status etc.). It is also common to forgo tasks and have each request represent an elementary task. Other methodologies are possible as well.
An example of using task-param:
#include "vely.h"

request-handler /customer
    task-param action
    input-param admin_id
    if-task "add"
        input-param customer_id
        // Add task
    else-task "delete"
        input-param customer_id
        // Delete task
    else-task "list"
        // List task

See if-task for more examples, including subtasks.
See also
Request information
See all

You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a link back to this page (dofollow) - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind.