kopia lustrzana https://github.com/c9/core
				
				
				
			Merge remote-tracking branch 'origin/master' into fix/ftp-mount-errorhandling
Conflicts: plugins/c9.ide.mount/ftp.js plugins/c9.ide.mount/mount.jspull/117/merge
						commit
						60234377c3
					
				| 
						 | 
				
			
			@ -15,6 +15,7 @@ module.exports = function Section(name, description, types) {
 | 
			
		|||
    var self = this;
 | 
			
		||||
    
 | 
			
		||||
    this.middlewares = [];
 | 
			
		||||
    this.globals = [];
 | 
			
		||||
    this.errorHandlers = [];
 | 
			
		||||
    this.name = name;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,10 +46,22 @@ module.exports = function Section(name, description, types) {
 | 
			
		|||
        });
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * Insert global middleware(s) for this section: The parent section is
 | 
			
		||||
     * always an empty container that delegates to it's sub-sections, and
 | 
			
		||||
     * executes all the middelwares for that section.
 | 
			
		||||
     * 
 | 
			
		||||
     * This method allows us to inject a "global" middleware that is inserted
 | 
			
		||||
     * *after* decodeParams and *before* all other middelwares.
 | 
			
		||||
     */
 | 
			
		||||
    this.global = function( middleware ){
 | 
			
		||||
        this.globals.push.apply(this.globals, flatten(middleware));
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    this.use = function(middleware) {
 | 
			
		||||
        this.middlewares.push.apply(this.middlewares, flatten(middleware));
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    this.error = function(middleware) {
 | 
			
		||||
        this.errorHandlers.push.apply(this.errorHandlers, flatten(middleware));
 | 
			
		||||
    };
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +83,13 @@ module.exports = function Section(name, description, types) {
 | 
			
		|||
        return section;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    this.mount = function(name, section) {
 | 
			
		||||
        if (!sections[name])
 | 
			
		||||
            sections[name] = [];
 | 
			
		||||
 | 
			
		||||
        sections[name].push(section);
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    this._rootHandler = function(req, res) {
 | 
			
		||||
        this.handle(req, res, function(err) {
 | 
			
		||||
            if (err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +125,7 @@ module.exports = function Section(name, description, types) {
 | 
			
		|||
        var method = req.method.toLowerCase();
 | 
			
		||||
        if (methods.indexOf(method) == -1)
 | 
			
		||||
            return next();
 | 
			
		||||
        
 | 
			
		||||
            
 | 
			
		||||
        var handler = this.match(req, path, method);
 | 
			
		||||
        if (!handler)
 | 
			
		||||
            return next();
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +138,9 @@ module.exports = function Section(name, description, types) {
 | 
			
		|||
            handler = handler.parent;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (this.globals.length)
 | 
			
		||||
            middleware.splice.apply( middleware, [1, 0].concat( this.globals ) );
 | 
			
		||||
 | 
			
		||||
        var i = 0;
 | 
			
		||||
        function processNext() {
 | 
			
		||||
            handler = middleware[i++];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,7 +67,7 @@
 | 
			
		|||
        "c9.ide.language.javascript.tern": "#7aab8b0b6a",
 | 
			
		||||
        "c9.ide.language.javascript.infer": "#cfec494a3c",
 | 
			
		||||
        "c9.ide.language.jsonalyzer": "#c253f093a0",
 | 
			
		||||
        "c9.ide.collab": "#aeaa248d54",
 | 
			
		||||
        "c9.ide.collab": "#f0e96dd2cf",
 | 
			
		||||
        "c9.ide.local": "#a9703b630c",
 | 
			
		||||
        "c9.ide.find": "#6cc6d3379d",
 | 
			
		||||
        "c9.ide.find.infiles": "#72582de3cd",
 | 
			
		||||
| 
						 | 
				
			
			@ -91,8 +91,8 @@
 | 
			
		|||
        "c9.ide.imgeditor": "#ed89162aa7",
 | 
			
		||||
        "c9.ide.immediate": "#6845a93705",
 | 
			
		||||
        "c9.ide.installer": "#3e6f7a72c9",
 | 
			
		||||
        "c9.ide.mount": "#74f50c40a7",
 | 
			
		||||
        "c9.ide.navigate": "#055a1f1a80",
 | 
			
		||||
        "c9.ide.mount": "#20339aeeaf",
 | 
			
		||||
        "c9.ide.navigate": "#f358997d93",
 | 
			
		||||
        "c9.ide.newresource": "#f1f0624768",
 | 
			
		||||
        "c9.ide.openfiles": "#28a4f5af16",
 | 
			
		||||
        "c9.ide.preview": "#0bd8dd6e8c",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ define(function(require, exports, module) {
 | 
			
		|||
 | 
			
		||||
        /***** Methods *****/
 | 
			
		||||
 | 
			
		||||
        var REST_METHODS = ["get", "post", "put", "delete"];
 | 
			
		||||
        var REST_METHODS = ["get", "post", "put", "delete", "patch"];
 | 
			
		||||
 | 
			
		||||
        function wrapMethod(urlPrefix, method) {
 | 
			
		||||
            return function(url, options, callback) {
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ define(function(require, exports, module) {
 | 
			
		|||
                }
 | 
			
		||||
                var headers = options.headers = options.headers || {};
 | 
			
		||||
                headers.Accept = headers.Accept || "application/json";
 | 
			
		||||
                options.method = method;
 | 
			
		||||
                options.method = method.toUpperCase();
 | 
			
		||||
                if (!options.timeout)
 | 
			
		||||
                    options.timeout = 60000;
 | 
			
		||||
                
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue