How to use the json.wrf function in json

To help you get started, we’ve selected a few json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geneontology / noctua / barista.js View on Github external
error_msg = 'You do not have permission for this operation.';
		}

		// Catch error here if no proper ID on non-public.
		res.setHeader('Content-Type', 'text/json');
		var eresp = {
		    message_type: 'error',
		    message: error_msg
		};
		var eresp_str = JSON.stringify(eresp);

		// If this was requested as AJAX, not CORS, need to
		// assemble it for the return.
		if( decoded_body && decoded_body['json.wrf'] ){
		    ll('adjust for AJAX call (POST)');
		    var envelope = decoded_body['json.wrf'];
		    eresp_str = envelope + '(' + eresp_str + ');';
		}

		//var eresp = new bbopx.barista.response(eresp_seed);
		ll('inject response:');
		ll(eresp_str);
		res.send(eresp_str);

	    }else{

		// Not public or user is privileged.
		// Route the simple call to the right place.
		//ll('req: ', req);
		// Clip "/api/" and the namespace.
		var api_loc = app_guard.app_target(ns);
		req.url = req.url.substr(ns.length + 5);
github o19s / splainer-search / splainer-search.js View on Github external
this.removeUnsupported = function(solrArgs) {
          var warnings = {};
          // Stuff I think we can safely remove without warning the user
          delete solrArgs['json.wrf'];
          delete solrArgs.facet;
          delete solrArgs['facet.field'];
          delete solrArgs.fl;
          delete solrArgs.hl;
          delete solrArgs['hl.simple.pre'];
          delete solrArgs['hl.simple.post'];
          delete solrArgs.wt;
          delete solrArgs.debug;

          // Unsupported stuff to remove and provide a friendly warning
          return warnings;
      };
    }
github geneontology / noctua / barista.js View on Github external
error_msg = 'You are using a bad token; please remove it.';
	    }else{
		error_msg = 'You do not have permission for this operation.';
	    }

	    // Catch error here if no proper ID on non-public.
	    res.setHeader('Content-Type', 'text/json');
	    var eresp = {
		message_type: 'error',
		message: error_msg
	    };
	    var eresp_str = JSON.stringify(eresp);

	    // If this was requested as AJAX, not CORS, need to
	    // assemble it for the return.
	    if( req && req['query'] && req['query']['json.wrf'] ){
		ll('adjust for AJAX call (GET)');
		var envelope = req['query']['json.wrf'];
		eresp_str = envelope + '(' + eresp_str + ');';
	    }

	    //var eresp = new bbopx.barista.response(eresp_seed);
	    ll('inject response:');
	    ll(eresp_str);
	    res.send(eresp_str);

	}else{

	    // Good call, so let's make a note of it--we're looking to
	    // get a little info on currently active users.
	    if( uuri ){
		monitor_last_op[uuri] = (new Date()).toJSON();
github geneontology / noctua / barista.js View on Github external
error_msg = 'You do not have permission for this operation.';
	    }

	    // Catch error here if no proper ID on non-public.
	    res.setHeader('Content-Type', 'text/json');
	    var eresp = {
		message_type: 'error',
		message: error_msg
	    };
	    var eresp_str = JSON.stringify(eresp);

	    // If this was requested as AJAX, not CORS, need to
	    // assemble it for the return.
	    if( req && req['query'] && req['query']['json.wrf'] ){
		ll('adjust for AJAX call (GET)');
		var envelope = req['query']['json.wrf'];
		eresp_str = envelope + '(' + eresp_str + ');';
	    }

	    //var eresp = new bbopx.barista.response(eresp_seed);
	    ll('inject response:');
	    ll(eresp_str);
	    res.send(eresp_str);

	}else{

	    // Good call, so let's make a note of it--we're looking to
	    // get a little info on currently active users.
	    if( uuri ){
		monitor_last_op[uuri] = (new Date()).toJSON();
	    }
github geneontology / noctua / barista.js View on Github external
error_msg = 'You are using a bad token; please remove it.';
		}else{
		    error_msg = 'You do not have permission for this operation.';
		}

		// Catch error here if no proper ID on non-public.
		res.setHeader('Content-Type', 'text/json');
		var eresp = {
		    message_type: 'error',
		    message: error_msg
		};
		var eresp_str = JSON.stringify(eresp);

		// If this was requested as AJAX, not CORS, need to
		// assemble it for the return.
		if( decoded_body && decoded_body['json.wrf'] ){
		    ll('adjust for AJAX call (POST)');
		    var envelope = decoded_body['json.wrf'];
		    eresp_str = envelope + '(' + eresp_str + ');';
		}

		//var eresp = new bbopx.barista.response(eresp_seed);
		ll('inject response:');
		ll(eresp_str);
		res.send(eresp_str);

	    }else{

		// Not public or user is privileged.
		// Route the simple call to the right place.
		//ll('req: ', req);
		// Clip "/api/" and the namespace.
github o19s / splainer-search / services / solrUrlSvc.js View on Github external
this.removeUnsupported = function(solrArgs) {
          var warnings = {};
          // Stuff I think we can safely remove without warning the user
          delete solrArgs['json.wrf'];
          delete solrArgs.facet;
          delete solrArgs['facet.field'];
          delete solrArgs.fl;
          delete solrArgs.hl;
          delete solrArgs['hl.simple.pre'];
          delete solrArgs['hl.simple.post'];
          delete solrArgs.wt;
          delete solrArgs.debug;

          // Unsupported stuff to remove and provide a friendly warning
          return warnings;
      };
    }