If you like BoxMatrix then please contribute Supportdata, Supportdata2, Firmware and/or Hardware (get in touch).
My metamonk@yahoo.com is not reachable by me since years. Please use hippie2000@webnmail.de instead.

0
U

Property:espresso.lua

From BoxMatrix


BoxMatrix >> Webinterface >> espresso.lua @ BoxMatrix   -   IRC-Chat   -   Translate: de es fr it nl pl
News Selectors Models Accessories Components Environment Config Commands System Webif Software Develop Lexicon Community Project Media

UI-Structure UI-Modules HTML-Files XML-Files Lua-Scripts Javascript Browser SSI-Files SSI-Directives HTML-Text Event-Text Help-Pages CSS-Files Graphics Research

Lua-Script

Goto:   Functions  -  Dependencies   -   Model-Matrix   -   SMW-Browser

Details

espresso.lua is the REST-API URL to function router. It is included by api.lua.

It creates a tree of function callbacks which are called depending on HTTP request URI and request method.

Excerpt from fw 7.50:

 Espresso is an url to function router for REST APIs.
 It is loosely designed after the node.js module Express (https:
 Further development should be go into the direction of the Express API.

usage:
 Create new router with:
  local app = Espresso.new()
 Configure the API by define
  app:get("/api/v0/overview", send_overview) -- gets called on GET requests to /api/v0/overview
  app:post("/api/v0/users", add_new_user) -- gets called on POST requests to /api/v0/users
 On incoming requests route the requests url and method to the configured callback
  app:call(url_path, method)
 Set optional default callback if given path/method combination could not be found:
  app:set_not_found_cb(callback_function)
 Generics:
 For variable paths to the same callback, a generic placeholders could be used.
  app:get("api/v0/<string>") -- routes GET requests like /api/v0/module1 or /api/v0/config3
 directly configured paths still has precedence over generics.
 A list with the generic url parts will be given to the callback function.

REST-API:

Functions

The function names of scripts often help to understand function blocks (and show gaps in the docs). fw 7.50 functions:

$ grep -e '^function' -e '^local function' /usr/rest_api/espresso.lua

# Create a new _FpTreeNode that is used for the Espresso search tree.
function _FpTreeNode.new()

# Find the next _FpTreeNode for a given URL part
function _FpTreeNode:find_next(url_part, generics)

# Create a new linked _FpTreeNode for the next part in an URL.
function _FpTreeNode:build_next(url_part)

# Split an URL path into a list of parts.
local function split_path(path_str)

# Create a new Espresso object.
function Espresso.new()

# Build necessary nodes in the search tree for a given URL path.
function Espresso._build_tree_branch(url, root_node)

# Find a search tree node for a given URL path.
function Espresso._find_tree_node(path, root_node)

# Register a callback on a HTTP get method.
function Espresso:get(path, fp)

# Register a callback on a HTTP post method.
function Espresso:post(path, fp)

# Register a callback on a HTTP put method.
function Espresso:put(path, fp)

# Register a callback on a HTTP delete method.
function Espresso:delete(path, fp)

# Register a callback on all HTTP methods.
function Espresso:all(path, fp)

# Define a callback that is used when no callback could be found for an url/method combination.
function Espresso:set_not_found_cb(fp)

# Search the tree for a registered callback and jump into it.
function Espresso:call(path, method_str) 

Dependencies

Daily updated index of all dependencies of this script. Last update: 2024-03-28 08:24 GMT.
A * in the Mod column marks info from Supportdata-Probes, which will always stay incomplete.
If an Object includes itself then this is a file with the same name but another Path and the dependencies are merged.

Relation Typ Object Mod Firmware Info Origin
Requires lua avmluamessages.lua 44 7.39 - 7.58 REST-API Debug Message Printer AVM
Required by lua api.lua 45 7.39 - 7.90 REST-API Lua-Land root for scgi_server AVM
2 dependencies for this script

Model-Matrix

Daily updated index of the presence, path and size of this script for each model. Last update: 2024-03-16 07:08 GMT.
Showing all models using this script. Click any column header (click-wait-click) to sort the list by the respective data.
The (main/scrpn/boot/arm/prx/atom) label in the Model column shows which CPU is meant for models with multiple Linux instances.
Note that this list is merged from Firmware-Probes of all known AVM firmware for a model, including Recovery.exe and Labor-Files.

Model Firmware Path Size/Bytes
0 models use this script

SMW-Browser

Information is currently being retrieved from the backend.
 

Synonyms

Showing 1 related property.

e