Modules (180)

UserServer

Description

Dependencies

Classes

Constructor

UserServer (extends BaseServer)

Live preview server for user specified server as defined with Live Preview Base Url Project setting. In a clean installation of Brackets, this is the highest priority server provider, if defined.

Configuration parameters for this server:

  • baseUrl - Optional base URL (populated by the current project)
  • pathResolver - Function to covert absolute native paths to project relative paths
  • root - Native path to the project root (and base URL)
config {baseUrl: string, root: string, pathResolver: function(string)}
    function UserServer(config) {
        BaseServer.call(this, config);
    }

    UserServer.prototype = Object.create(BaseServer.prototype);
    UserServer.prototype.constructor = UserServer;

Methods

canServe

Determines whether we can serve local file.

localPath string
A local path to file being served.
Returns: boolean
true for yes, otherwise false.
    UserServer.prototype.canServe = function (localPath) {
        // UserServer can only function when the project specifies a base URL
        if (!this._baseUrl) {
            return false;
        }

        // If we can't transform the local path to a project relative path,
        // the path cannot be served
        if (localPath === this._pathResolver(localPath)) {
            return false;
        }

        return LiveDevelopmentUtils.isStaticHtmlFileExt(localPath) ||
            LiveDevelopmentUtils.isServerHtmlFileExt(localPath);
    };

    exports.UserServer = UserServer;
});