dba/logs
library moduleR
Summary
Download log file.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : logs/log-download.xqm
Imports
This module is imported by 0 modules. It imports 0 modules.
Variables
Functions
4.1 dba:log-download
Arities: dba:log-download#1R
dba:log-download
(
$name
as
xs:string
)
as
item() +
- name
as
xs:string
name (date) of log file
item() +
binary data
Invokes 3 functions from 3 modules
- {http://basex.org/modules/db}option#1
- {http://basex.org/modules/web}response-header#2
- {http://expath.org/ns/file}read-binary#1
Invoked by 0 functions from 0 modules
Annotations
%rest:POST | () |
%rest:path | ('/dba/log-download') |
%rest:query-param | ('name','{$name}') |
Source ( 9 lines)
function dba:log-download(
$name as xs:string
) as item()+ {
web:response-header(
map { 'media-type': 'text/plain' },
map { 'Content-Disposition': 'attachment; filename=' || $name || '.log' }
),
file:read-binary(db:option('dbpath') || '/.logs/' || $name || '.log')
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
dba | dba/logs 2 3 |
rest | http://exquery.org/ns/restxq |
Source Code
(:~
: Download log file.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/logs';
(:~ Top category :)
declare variable $dba:CAT := 'logs';
(:~
: Downloads database logs.
: @param $name name (date) of log file
: @return binary data
:)
declare
%rest:POST
%rest:path('/dba/log-download')
%rest:query-param('name', '{$name}')
function dba:log-download(
$name as xs:string
) as item()+ {
web:response-header(
map { 'media-type': 'text/plain' },
map { 'Content-Disposition': 'attachment; filename=' || $name || '.log' }
),
file:read-binary(db:option('dbpath') || '/.logs/' || $name || '.log')
};