web::match
result
listToBeSearched
searchFor
In case searchFor
exists in
listToBeSearched
, web::match returns
result
, otherwise an empty string.
web::match treats listToBeSearched as a list. Thus, web::match "ok" {tv dvd vcr} dvd will return ok.
web::tempfile
?options
?
Options are -path path
,
-prefix prefix
, and -remove.
web::tempfile
?-path
path
? ?-prefix
prefix
?
Returns a unique name of a temporary file in the default
temp directory or the directory given with
path
.
The name can be prefixed with prefix
.
The maximum of guaranteed unique names per application is system
dependent. This command just returns the name of a file. It is the
programmers job to handle the file, for example to open
it. Note that Websh keeps an internal list of all file
names generated with web::tempfile and will
attempt to delete all files when the interpreter dies.
web::tempfile
-removeThe -remove option attemps to clean up all temporary files previously created using web::tempfile and resets the internal list of these file names.
Generates an ISO‐8601 timestamp. If the optional parameter ms
(milliseconds) is not a valid wide integer, the current system time (from clock milliseconds
) is used.
web::ts
?ms
?
Example: web::ts
→ "2025-02-19T12:34:56.789"
Initializes the configuration context by assigning the provided context to the variable configContext
and calling web::context
internally.
web::configSetup
?context
?
Initializes the session context. Stores the provided context in sessionContext
, creates a UUID v4 based ID generator via web::filerandom
, and calls web::filecontext
with the appropriate path, ID generator, and disabled encryption (crypt off
).
web::sessionSetup
?context
?
Configures logging by adding the specified logging level via web::loglevel add
and adding a log destination (e.g. syslog) with a custom format. The optional syslog
parameter sets the priority (default: 10).
web::loggingSetup
level
?syslog
?
Returns a dictionary containing the current session data. The dictionary includes keys such as iss
(Issuer), sub
(Subject), aud
(Audience), exp
(Expiration Time), nbf
(Not Before), iat
(Issued At), jti
(JWT ID), and mlt
(Max Life Time).
web::sessionGet
Creates a new session. It computes session validity based on the current time and the provided timeout
(default: 3600000 ms), sets parameters such as Issuer (from SERVER_NAME
), Subject, Audience, Expiration Time, Not Before, Issued At, and JWT ID (via sessionContext::id
), and optionally maximum lifetime (mlt
). A JSON string with the session data is sent via the response header X-Session
.
web::sessionNew
?timeout
?subject
?audience
?maxlifetime
?
Initializes an existing session using an AUTH_BEARER
token obtained via web::request
. Returns false if no token is found, if initialization fails, or if the session is already marked as closed; otherwise, updates the session tag and logging.
web::sessionInit
Closes the current session by setting the sessionClosed
flag and committing the change. Also, sets the response header X-Status
to "sessionClosed" and returns the current session data.
web::sessionClose
Refreshes the session if it is still active by updating the expiration time based on the provided timeout
(default: 3600000 ms). If the session has expired (based on the exp
and mlt
values), the session is closed.
web::sessionRefresh
?timeout
?
Generates a UUID version 4 by obtaining 16 random bytes, adjusting specific bits as specified by the UUIDv4 standard, and formatting the result as a string in the format 8-4-4-4-12.
web::uuidV4
Retrieves the request content. If a CONTENT_ENCODING
is specified and supported by Tcl, converts the content from that encoding; otherwise, returns the raw CONTENT_DATA
.
web::getContent
Determines the MIME type based on a given token. Supported tokens include: bin
, bz2
, csv
, docx
, gz
, ics
, jpg
, json
, png
, pdf
, rtf
, svg
, txt
, xlsx
, xml
, zip
, 7z
. If the token is not recognized, returns the original token.
web::mimeType
token
Sends a JSON response. Configures the response channel with UTF-8 encoding, sets appropriate headers (Content-Type, Content-Length, Cache-Control, etc.), sends the JSON data via web::put
, and resets the response.
web::returnJson
json
Sends a text response. Sets the specified encoding (default: utf-8) and MIME type, calculates the content length, sets cache control headers, outputs the text via web::put
, and resets the response.
web::returnText
mimetype
data
?encoding
?
Sends a binary response, typically used for file downloads. Sets the response channel to binary mode, configures headers (Content-Type
, Content-Length
, Content-Disposition
with the specified filename), sets cache control headers, sends the binary data via web::put
, and resets the response.
web::returnBinary
mimetype
data
filename