From 5eafa1a8efedbd3341eb3de08d34bf6d334c3f0f Mon Sep 17 00:00:00 2001 From: adrien Date: Sun, 22 Apr 2018 11:24:12 +0200 Subject: [PATCH] Added an example to display how to add logs --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 9690f356..c3f41cde 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,29 @@ const server = new webdav.WebDAVServer({ server.start(() => console.log('READY')); ``` +With some logs : + +```javascript +// TypeScript +import { v2 as webdav } from 'webdav-server' +// JavaScript +const webdav = require('webdav-server').v2; + +const server = new webdav.WebDAVServer({ + port: 1900 +}); + +server.afterRequest((arg, next) => { + // Display the method, the URI, the returned status code and the returned message + console.log('>>', arg.request.method, arg.uri, '>', arg.response.statusCode, arg.response.statusMessage); + // If available, display the body of the response + console.log(arg.responseBody); + next(); +}); + +server.start(() => console.log('READY')); +``` + With a user manager, privilege manager and serialization (save/load the state of the server) : ```javascript