Skip to content

Commit

Permalink
Added the 'CreateExternalContext' method to the server class to ease …
Browse files Browse the repository at this point in the history
…the creation of external contexts
  • Loading branch information
AdrienCastex committed Jun 28, 2017
1 parent 5c987c6 commit 358e2ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 8 additions & 3 deletions lib/server/v2/webDAVServer/WebDAVServer.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/// <reference types="node" />
import { WebDAVServerOptions } from '../WebDAVServerOptions';
import { RequestContext, HTTPMethod } from '../WebDAVRequest';
import { RequestContext, RequestContextExternalOptions } from '../RequestContext';
import { HTTPMethod } from '../WebDAVRequest';
import { HTTPAuthentication } from '../../../user/v2/authentication/HTTPAuthentication';
import { IPrivilegeManager } from '../../../user/v2/privilege/IPrivilegeManager';
import { PrivilegeManager } from '../../../user/v2/privilege/PrivilegeManager';
import { FileSystem } from '../../../manager/v2/fileSystem/FileSystem';
import { ReturnCallback } from '../../../manager/v2/fileSystem/CommonTypes';
import { Resource } from '../../../manager/v2/fileSystem/Resource';
Expand All @@ -15,7 +16,7 @@ import * as http from 'http';
export declare type WebDAVServerStartCallback = (server?: http.Server) => void;
export declare class WebDAVServer {
httpAuthentication: HTTPAuthentication;
privilegeManager: IPrivilegeManager;
privilegeManager: PrivilegeManager;
options: WebDAVServerOptions;
methods: {
[methodName: string]: HTTPMethod;
Expand All @@ -28,6 +29,10 @@ export declare class WebDAVServer {
[path: string]: FileSystem;
};
constructor(options?: WebDAVServerOptions);
createExternalContext(): RequestContext;
createExternalContext(callback: (error: Error, ctx: RequestContext) => void): RequestContext;
createExternalContext(options: RequestContextExternalOptions): RequestContext;
createExternalContext(options: RequestContextExternalOptions, callback: (error: Error, ctx: RequestContext) => void): RequestContext;
rootFileSystem(): FileSystem;
getResource(ctx: RequestContext, path: Path | string, callback: ReturnCallback<Resource>): void;
setFileSystem(path: Path | string, fs: FileSystem, callback: (successed?: boolean) => void): void;
Expand Down
4 changes: 4 additions & 0 deletions lib/server/v2/webDAVServer/WebDAVServer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WebDAVServerOptions_1 = require("../WebDAVServerOptions");
var RequestContext_1 = require("../RequestContext");
var Commands_1 = require("../commands/Commands");
var Path_1 = require("../../../manager/v2/Path");
var persistence = require("./Persistence");
Expand Down Expand Up @@ -30,6 +31,9 @@ var WebDAVServer = (function () {
else
this.method(k, new commands[k]());
}
WebDAVServer.prototype.createExternalContext = function (_options, _callback) {
return RequestContext_1.RequestContext.createExternal(this, _options, _callback);
};
WebDAVServer.prototype.rootFileSystem = function () {
return this.fileSystems['/'];
};
Expand Down
15 changes: 12 additions & 3 deletions src/server/v2/webDAVServer/WebDAVServer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { WebDAVServerOptions, setDefaultServerOptions } from '../WebDAVServerOptions'
import { HTTPCodes, RequestContext, HTTPMethod } from '../WebDAVRequest'
import { RequestContext, RequestContextExternalOptions } from '../RequestContext'
import { HTTPCodes, HTTPMethod } from '../WebDAVRequest'
import { HTTPAuthentication } from '../../../user/v2/authentication/HTTPAuthentication'
import { IPrivilegeManager } from '../../../user/v2/privilege/IPrivilegeManager'
import { PrivilegeManager } from '../../../user/v2/privilege/PrivilegeManager'
import { FileSystem } from '../../../manager/v2/fileSystem/FileSystem'
import { ReturnCallback } from '../../../manager/v2/fileSystem/CommonTypes'
import { Resource } from '../../../manager/v2/fileSystem/Resource'
Expand All @@ -21,7 +22,7 @@ export type WebDAVServerStartCallback = (server ?: http.Server) => void;
export class WebDAVServer
{
public httpAuthentication : HTTPAuthentication
public privilegeManager : IPrivilegeManager
public privilegeManager : PrivilegeManager
public options : WebDAVServerOptions
public methods : { [methodName : string]: HTTPMethod }

Expand Down Expand Up @@ -56,6 +57,14 @@ export class WebDAVServer
this.method(k, new commands[k]());
}

createExternalContext() : RequestContext
createExternalContext(callback : (error : Error, ctx : RequestContext) => void) : RequestContext
createExternalContext(options : RequestContextExternalOptions) : RequestContext
createExternalContext(options : RequestContextExternalOptions, callback : (error : Error, ctx : RequestContext) => void) : RequestContext
createExternalContext(_options ?: RequestContextExternalOptions | ((error : Error, ctx : RequestContext) => void), _callback ?: (error : Error, ctx : RequestContext) => void) : RequestContext
{
return RequestContext.createExternal(this, _options, _callback);
}

rootFileSystem() : FileSystem
{
Expand Down

0 comments on commit 358e2ee

Please sign in to comment.