dba/logs
library moduleR
Summary
Download log file.
- Authors
- Christian Grün, BaseX Team 2005-23, BSD License
Imports
This module is imported by 0 modules. It imports 0 modules.
Variables
Functions
4.1 dba:log-download
Arities: #1R
dba:log-download
(
$name
as
xs:string
) as
item()+
- name
as
xs:string
name (date) of log file
item() +
binary data
Invoked by 0 functions from 0 modules
Annotations (3)
%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 |
---|---|
db | http://basex.org/modules/db |
dba | dba/logs 2 |
file | http://expath.org/ns/file |
rest | http://exquery.org/ns/restxq |
web | http://basex.org/modules/web |
xs | http://www.w3.org/2001/XMLSchema |
Source Code
(:~
: Download log file.
:
: @author Christian Grün, BaseX Team 2005-23, 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')
};