dba/logs  library module
R

Summary

Download log file.
Tags

Author: Christian Grün, BaseX Team 2005-21, BSD License

__source : logs/log-download.xqm

Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 0 modules.

Variables

3.1 $dba:CAT

Summary
Top category
Type
xs:string

Functions

4.1 dba:log-download

Arities: dba:log-download#1R

Summary
Downloads database logs.
Signature
dba:log-download ( $name as xs:string )  as item()+
Parameters
  • name as xs:string name (date) of log file
Return
  • 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:

    PrefixUri
    dbadba/logs 2 3
    resthttp://exquery.org/ns/restxq

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/log-downloadPOSTdba:log-download#1

    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')
    };