FAQ
-
Why doesn't the code in this guide work with my installation?
You are probably using a version of the AmesPAHdbIDLSuite dated prior February 14, 2015. Please update to a newer version.
-
Does the AmesPAHdbIDLSuite work with GDL?
The AmesPAHdbIDLSuite might work with GDL, the open source alternative to IDL.
-
How does the AmesPAHdbIDLSuite deal with color output?
The AmesPAHdbIDLSuite 'Plot'-methods create and load a color table containing 15 colors. When outputting to screen, the device will be set into discrete graphics mode. Upon completion, both the color table and the display mode will be restored to their initial settings.
-
Where have the C-routines gone?
The C-code has been removed from the AmesPAHdbIDLSuite for three reasons. First, The NNLS implementation in the suite now makes use of IDL’s LA_LEAST_SQUARES-routine, which is implemented using LAPACK and therefore very fast. Second, it appears that IDL’s READS-routine has seen some significant speed improvements in recent IDL releases such that the CONVERT_ASCII C-implementation has become obsolete. Third and last, making the C-routines compile and reliable across multiple platforms has proven to be difficult.
-
I am getting schema validation errors, is this an issue and how can I get rid of them?
Schema validation errors typically do not cause a problem. The errors you see could be related to the move from www.astrochem.org to www.astrochemistry.org for the base URL, affecting the used XML namespaces. Re-downloading your database XML-file should solve the problem. As a last resort, you can disable schema validation by setting the 'Check'-keyword to 'Check=0' when creating the AmesPAHdbIDLSuite-object.
-
I am getting an unsupported protocol in URL error, what can I do?
With the recent move to using SSL (https) on our domain (www.astrochemistry.org) IDL's XML-parser fails to download the linked schema for checking the structure of the database file. By setting the 'CHECK'-keyword to '0' in the OBJ_NEW-call will mitigate the problem. Note that you might need to manually remove the corrupted cache file.
-
I am receiving an invalid multi-byte sequence error, what can I do?
It has been reported that on older versions of some operating systems IDL's XML-parser is unable to properly handle the utf-8 characters embedded in the database XML-file. One solution is to move to a more modern version of your operation system. Another possible solution is converting the file to use a different encoding with the following command.
Note that characters that cannot be converted are simply removed.xmllint --encode latin1 --output converted.xml file_with_UTF-8.xml


Miami GP receives another lifeline from city mayor!
by Adam NewtonThe mayor of Miami has issued a veto against those who oppose the event, handing it another lifeline in its battle to become a Formula 1 Grand Prix. F1's owners, Liberty Media, have identified Miami as one of it's 'destination cities' and seems very keen to host a race there.
The track is set to be based around the Miami Dolphins' Hard Rock Stadium, but a county commissioner for Miami Gardens spoke out against the race, and her attempt to block it was passed by a vote late last month.
However, Miami-Dade mayor Carlos Giminez has breathed life back into the plans with his veto, encouraging both sides to find an acceptable agreement to allow the race to run.
He said in a statement that he didn't want to see a "premature to attempt to block an event of the magnitude of Formula One outright."
Giminez continued: "I remain committed to respecting the residents of Miami Gardens, and I remain committed to finding a way to bring this world-class event to our community."
The veto will go to a vote soon, so hang tight! In the meantime, what do you make of Liberty Media's 'destination cities'?


'Can't afford to lose' - Dean Smith urged to warn at risk Aston Villa ace
Aston Villa latest news | The defender is walking a disciplinary tightrope with games against Newcastle, Man United and Chelsea on the horizon
by Ben Husband, https://www.birminghammail.co.uk/authors/ben-husband/Former Aston Villa striker Darren Bent has told Dean Smith he needs to have 'a quiet word with Frederic Guilbert ahead of a potential, costly suspension.
The Frenchman has been in fine form since his introduction into the Villa squad in the summer. But against Wolves, he amassed his fourth booking of the season, meaning he now walks a disciplinary tightrope.
The cut-off for a ban for yellow card accumulation is still a number of weeks away, meaning that he could miss a game in a tough looking run of fixtures.
Villa host Newcastle next, before games against top four hopefuls Chelsea, Man United and Leicester City.
And Bent believes Smith needs to tell Guilbert, who has picked up 25 cautions since the start of the 2017/18 season, to 'ease off the gas'.
He told Football Insider: “I’m not sure he will (be sweating) just because when Dean Smith signed him, he knew about this record so it obviously doesn’t bother him that much but you’d like to think that Smith has had a quiet word with him and say ‘listen, take your foot off the gas a little bit as we can’t afford to lose you for games’.
“But at the same time, he can’t really have any complaints as he knew the record when he signed him.”
Aston Villa latest
This is your round up of all things Villa; the one-stop shop that will keep you updated on the latest goings on at the club and beyond.
Transfers, injuries, match-days and managers, we’ve got you covered.
We’ll be bringing the very latest on the Villains throughout the week and around the clock.
Make sure you keep yourself updated with our handy daily catch up...
Must reads...
- Villa fans make Chelsea transfer demand
- 'Worried' fans react to major announcement
- Former Villan reveals Newcastle bombshell
- Morelos saga takes new twist
For all your latest AVFC news, opinion, analysis and transfer gossip, click here
You can follow our Villa reporter Ashley Preece on Twitter, and his email address is Ashley.Preece@reachplc.com.


covid-dz
Get All Algeria Covid info here
Algeria Covid-19 Statistics
Active
Confirmed
Deaths
Recovered
Active Covid Cases Graph
Confirmed Covid Cases Graph
Covid deaths Graph


Hello!
By night I am a Human-Centred Systems MSc student at City University London. By day, a Software Engineer.
I am presently looking for small freelance jobs and/or full-time work opportunities. Feel free to check out my CV and get in touch.
As part of my studies I am interested in conducting user research, information architecture and interaction design for projects in healthcare.


Broward Exchange was originally formed with the struggle of the college student in mind. Relieving the stress of home clutter has never been easier - we're here to give you the peace of mind that comes with no-stress item exchange. Whether you're here to buy, sell, take, trade, or give away, our algorithms are built to ensure you get what you need and get rid of what you don't.
Initiate, plan, coordinate project.
Creating that awesome user-friendly experience.
Working behind the scene/server side,ensuring that administrative tasks will operate smoothly.


4.x API
express()
Creates an Express application. The express()
function is a top-level function exported by the express module.
var express = require('express');
var app = express();
Application
The app
object conventionally denotes the Express application.
Create it by calling the top-level express()
function exported by the Express module:
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('hello world');
});
app.listen(3000);
The app
object has a methods for
- Routing HTTP requests; see for example, app.METHOD and app.param.
- Configuring middleware; see app.route.
- Rendering HTML views; see app.render.
- Registering a template engine; see app.engine.
It also has settings (properties) that affect how the application behaves; for more information, see Application settings.
Properties
app.locals
The app.locals
object is a JavaScript object, and its
properties are local variables within the application.
app.locals.title
// => 'My App'
app.locals.email
// =><EMAIL_ADDRESS>Once set, the value of app.locals
properties persist throughout the life of the application,
in contrast with res.locals properties that
are valid only for the lifetime of the request.
You can accesss local variables in templates rendered within the application. This is useful for providing helper functions to templates, as well as app-level data. Note, however, that you cannot access local variables in middleware.
app.locals.title = 'My App';
app.locals.strftime = require('strftime');
app.locals.email =<EMAIL_ADDRESS>app.mountpath
The app.mountpath
property is the path pattern(s) on which a sub app was mounted.
A sub app is an instance of express
which may be used for handling the request to a route.
var express = require('express');
var app = express(); // the main app
var admin = express(); // the sub app
admin.get('/', function (req, res) {
console.log(admin.mountpath); // /admin
res.send('Admin Homepage');
})
app.use('/admin', admin); // mount the sub app
It is similar to the baseUrl property of the req
object, except req.baseUrl
returns the matched URL path, instead of the matched pattern(s).
If a sub-app is mounted on multiple path patterns, app.mountpath
returns the list of patterns it is mounted on, as shown in the following example.
var admin = express();
admin.get('/', function (req, res) {
console.log(admin.mountpath); // [ '/adm*n', '/manager' ]
res.send('Admin Homepage');
})
var secret = express();
secret.get('/', function (req, res) {
console.log(secret.mountpath); // /secr*t
res.send('Admin Secret');
});
admin.use('/secr*t', secret); // load the 'secret' router on '/secr*t', on the 'admin' sub app
app.use(['/adm*n', '/manager'], admin); // load the 'admin' router on '/adm*n' and '/manager', on the parent app
Events
app.on('mount', callback(parent))
The mount
event is fired on a sub-app, when it is mounted on a parent app. The parent app is passed to the callback function.
var admin = express();
admin.on('mount', function (parent) {
console.log('Admin Mounted');
console.log(parent); // refers to the parent app
});
admin.get('/', function (req, res) {
res.send('Admin Homepage');
});
app.use('/admin', admin);
Methods
app.all(path, callback [, callback ...])
This method is like the standard app.METHOD() methods, except it matches all HTTP verbs.
It’s useful for mapping “global” logic for specific path prefixes or arbitrary matches.
For example, if you put the following at the top of all other
route definitions, it requires that all routes from that point on
require authentication, and automatically load a user. Keep in mind
that these callbacks do not have to act as end-points: loadUser
can perform a task, then call next()
to continue matching subsequent
routes.
app.all('*', requireAuthentication, loadUser);
Or the equivalent:
app.all('*', requireAuthentication)
app.all('*', loadUser);
Another example is white-listed “global” functionality. The example is much like before, however it only restricts paths that start with “/api”:
app.all('/api/*', requireAuthentication);
app.delete(path, callback [, callback ...])
Routes HTTP DELETE requests to the specified path with the specified callback functions. For more information, see the routing guide.
You can provide multiple callback functions that behave just like middleware, except
these callbacks can invoke next('route')
to bypass the remaining route
callback(s). You can use this mechanism to impose pre-conditions on a route, then pass control
to subsequent routes if there’s no reason to proceed with the current route.
app.delete('/', function (req, res) {
res.send('DELETE request to homepage');
});
app.disable(name)
Sets the Boolean setting name
to false
, where name
is one of the properties from the app settings table.
Calling app.set('foo', false)
for a Boolean property is the same as calling app.disable('foo')
.
For example:
app.disable('trust proxy');
app.get('trust proxy');
// => false
app.disabled(name)
Returns true
if the Boolean setting name
is disabled (false
), where name
is one of the properties from
the app settings table.
app.disabled('trust proxy');
// => true
app.enable('trust proxy');
app.disabled('trust proxy');
// => false
app.enable(name)
Sets the Boolean setting name
to true
, where name
is one of the properties from the app settings table.
Calling app.set('foo', true)
for a Boolean property is the same as calling app.enable('foo')
.
app.enable('trust proxy');
app.get('trust proxy');
// => true
app.enabled(name)
Returns true
if the setting name
is enabled (true
), where name
is one of the
properties from the app settings table.
app.enabled('trust proxy');
// => false
app.enable('trust proxy');
app.enabled('trust proxy');
// => true
app.engine(ext, callback)
Registers the given template engine callback
as ext
.
By default, Express will require()
the engine based on the file extension.
For example, if you try to render a “foo.jade” file, Express invokes the
following internally, and caches the require()
on subsequent calls to increase
performance.
app.engine('jade', require('jade').__express);
Use this method for engines that do not provide .__express
out of the box,
or if you wish to “map” a different extension to the template engine.
For example, to map the EJS template engine to “.html” files:
app.engine('html', require('ejs').renderFile);
In this case, EJS provides a .renderFile()
method with
the same signature that Express expects: (path, options, callback)
,
though note that it aliases this method as ejs.__express
internally
so if you’re using “.ejs” extensions you don’t need to do anything.
Some template engines do not follow this convention. The consolidate.js library maps Node template engines to follow this convention, so they work seemlessly with Express.
var engines = require('consolidate');
app.engine('haml', engines.haml);
app.engine('html', engines.hogan);
app.get(name)
Returns the value of name
app setting, where name
is one of strings in the
app settings table. For example:
app.get('title');
// => undefined
app.set('title', 'My Site');
app.get('title');
// => "My Site"
app.get(path, callback [, callback ...])
Routes HTTP GET requests to the specified path with the specified callback functions. For more information, see the routing guide.
You can provide multiple callback functions that behave just like middleware, except
these callbacks can invoke next('route')
to bypass the remaining route callback(s).
You can use this mechanism to impose pre-conditions on a route, then pass control to
subsequent routes if there’s no reason to proceed with the current route.
app.get('/', function (req, res) {
res.send('GET request to homepage');
});
app.listen(port, [hostname], [backlog], [callback])
Binds and listens for connections on the specified host and port. This method is identical to Node’s http.Server.listen().
var express = require('express');
var app = express();
app.listen(3000);
The app
returned by express()
is in fact a JavaScript
Function
, designed to be passed to Node’s HTTP servers as a callback
to handle requests. This makes it easy to provide both HTTP and HTTPS versions of
your app with the same code base, as the app does not inherit from these
(it is simply a callback):
var express = require('express');
var https = require('https');
var http = require('http');
var app = express();
http.createServer(app).listen(80);
https.createServer(options, app).listen(443);
The app.listen()
method is a convenience method for the following (for HTTP only):
app.listen = function() {
var server = http.createServer(this);
return server.listen.apply(server, arguments);
};
app.METHOD(path, callback [, callback ...])
Routes an HTTP request, where METHOD is the HTTP method of the request, such as GET,
PUT, POST, and so on, in lowercase. Thus, the actual methods are app.get()
,
app.post()
, app.put()
, and so on. See below for the complete list.
For more information, see the routing guide.
Express supports the following routing methods corresponding to the HTTP methods of the same names:
|
|
|
To route methods which translate to invalid JavaScript variable names, use the bracket notation. For example,
app['m-search']('/', function ...
.
You can provide multiple callback functions that behave just like middleware, except
that these callbacks can invoke next('route')
to bypass
the remaining route callback(s). You can use this mechanism to impose pre-conditions
on a route, then pass control to subsequent routes if there is no reason to proceed with the current route.
The API documentation has explicit entries only for the most popular HTTP methods app.get()
,
app.post()
, app.put()
, and app.delete()
.
However, the other methods listed above work in exactly the same way.
There is a special routing method, app.all()
, that is not derived from any HTTP method.
It loads middleware at a path for all request methods.
In the following example, the handler is executed for requests to “/secret” whether using GET, POST, PUT, DELETE, or any other HTTP request method.
app.all('/secret', function (req, res, next) {
console.log('Accessing the secret section ...')
next() // pass control to the next handler
})
app.param([name], callback)
Add callback triggers to route parameters, where name
is the name of the parameter or an array of them, and function
is the callback function. The parameters of the callback function are the request object, the response object, the next middleware, and the value of the parameter, in that order.
For example, when :user
is present in a route path, you may map user loading logic to automatically provide req.user
to the route, or perform validations on the parameter input.
app.param('user', function(req, res, next, id) {
// try to get the user details from the User model and attach it to the request object
User.find(id, function(err, user) {
if (err) {
next(err);
} else if (user) {
req.user = user;
next();
} else {
next(new Error('failed to load user'));
}
});
});
Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on app
will be triggered only by route parameters defined on app
routes.
A param callback will be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following example.
app.param('id', function (req, res, next, id) {
console.log('CALLED ONLY ONCE');
next();
})
app.get('/user/:id', function (req, res, next) {
console.log('although this matches');
next();
});
app.get('/user/:id', function (req, res) {
console.log('and this matches too');
res.end();
});
app.param(callback)
is deprecated as of v4.11.0.
By passing only a callback function, you can alter the app.param()
API. For example the express-params defines the following callback which allows you to restrict parameters to a given regular expression.
The code in the next section can be migrated using the following, without the use of app.param(callback)
:
router.get('/user/:id([0-9]+)', function(req, res){ res.send('user ' + req.params.id); }); router.get('/range/:range(\\w+\.\.\\w+)', function(req, res){ var range = req.params.range.split('..'); res.send('from ' + range[0] + ' to ' + range[1]); });
app.param(function(name, fn) {
if (fn instanceof RegExp) {
return function(req, res, next, val) {
var captures;
if (captures = fn.exec(String(val))) {
req.params[name] = captures;
next();
} else {
next('route');
}
}
}
});
The method could now be used to effectively validate parameters (and optionally parse them to provide capture groups):
// validation rule for id: should be one or more digits
app.param('id', /^\d+$/);
app.get('/user/:id', function(req, res) {
res.send('user ' + req.params.id);
});
// validation rule for range: should start with one more alphanumeric characters, followed by two dots, and end with one more alphanumeric characters
app.param('range', /^(\w+)\.\.(\w+)?$/);
app.get('/range/:range', function(req, res) {
var range = req.params.range;
res.send('from ' + range[1] + ' to ' + range[2]);
});
app.path()
Returns the canonical path of the app, a string.
var app = express()
, blog = express()
, blogAdmin = express();
app.use('/blog', blog);
blog.use('/admin', blogAdmin);
console.log(app.path()); // ''
console.log(blog.path()); // '/blog'
console.log(blogAdmin.path()); // '/blog/admin'
The behavior of this method can become very complicated in complex cases of mounted apps: it is usually better to use req.baseUrl to get the canonical path of the app.
app.post(path, callback [, callback ...])
Routes HTTP POST requests to the specified path with the specified callback functions. For more information, see the routing guide.
You can provide multiple callback functions that behave just like middleware,
except that these callbacks can invoke next('route')
to bypass the
remaining route callback(s). You can use this mechanism to impose pre-conditions on
a route, then pass control to subsequent routes if there’s no reason to proceed with
the current route.
app.post('/', function (req, res) {
res.send('POST request to homepage');
});
app.put(path, callback [, callback ...])
Routes HTTP PUT requests to the specified path with the specified callback functions. For more information, see the routing guide.
You can provide multiple callback functions that behave just like middleware,
except that these callbacks can invoke next('route')
to bypass the
remaining route callback(s). You can use this mechanism to impose pre-conditions on
a route, then pass control to subsequent routes if there’s no reason to proceed with
the current route.
app.put('/', function (req, res) {
res.send('PUT request to homepage');
});
app.render(view, [locals], callback)
Returns the rendered HTML of a view via the callback
function. It accepts an optional parameter
that is an object containing local variables for the view. It is like res.render(),
except it cannot send the rendered view to the client on its own.
Think of app.render()
as a utility function for generating rendered view strings.
Internally res.render()
uses app.render()
to render views.
The local variable cache
is reserved for enabling view cache. Set it to true
, if you want to
cache view during development; view caching is enabled in production by default.
app.render('email', function(err, html){
// ...
});
app.render('email', { name: 'Tobi' }, function(err, html){
// ...
});
app.route(path)
Returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware.
Use app.route()
to avoid duplicate route names (and thus typo errors).
var app = express();
app.route('/events')
.all(function(req, res, next) {
// runs for all HTTP verbs first
// think of it as route specific middleware!
})
.get(function(req, res, next) {
res.json(...);
})
.post(function(req, res, next) {
// maybe add a new event...
})
app.set(name, value)
Assigns setting name
to value
, where name
is one of the properties from
the app settings table.
Calling app.set('foo', true)
for a Boolean property is the same as calling
app.enable('foo')
. Similarly, calling app.set('foo', false)
for a Boolean
property is the same as calling app.disable('foo')
.
Retrieve the value of a setting with app.get()
.
app.set('title', 'My Site');
app.get('title'); // "My Site"
Application Settings
If name
is one of the application settings, it affects the behavior of the application. The following table lists application settings.
| Property | Type | Value | Default |
|---|---|---|---|
|
|
Boolean | Enable case sensitivity. | Disabled. Treats "/Foo" and "/foo" as the same. |
|
|
String | Environment mode. |
|
|
|
Varied |
Set the ETag response header. For possible values, see the |
|
|
|
String | Specifies the default JSONP callback name. |
|
|
|
String | JSON replacer callback. |
|
|
|
Number | When set, sends prettified JSON string indented with the specified amount of spaces. | Disabled. |
|
|
String |
The query parser to use, either “simple” or “extended”. The simple query parser is based on Node’s native query parser, querystring. The extended query parser is based on qs. |
"extended" |
|
|
Boolean | Enable strict routing. | Disabled. Treats "/foo" and "/foo/" as the same by the router. |
|
|
Number | The number of dot-separated parts of the host to remove to access subdomain. | 2 |
|
|
Varied |
Indicates the app is behind a front-facing proxy, and to use the
The |
Disabled. |
|
|
String or Array | A directory or an array of directories for the application's views. If an array, the views are looked up in the order they occur in the array. |
|
|
|
Boolean | Enables view template compilation caching. |
|
|
|
String | The default engine extension to use when omitted. | |
|
|
Boolean | Enables the "X-Powered-By: Express" HTTP header. |
|
Options for `trust proxy` setting
| Type | Value |
|---|---|
| Boolean |
If If |
| IP addresses |
An IP address, subnet, or an array of IP addresses, and subnets to trust. The following is the list of pre-configured subnet names.
Set IP addresses in any of the following ways:
When specified, the IP addresses or the subnets are excluded from the address determination process, and the untrusted IP address nearest to the application server is determined as the client’s IP address. |
| Number |
Trust the |
| Function |
Custom trust implementation. Use this only if you know what you are doing.
|
Options for `etag` setting
| Type | Value |
|---|---|
| Boolean |
|
| String |
If "strong", enables strong ETag. If "weak", enables weak ETag. |
| Function |
Custom ETag function implementation. Use this only if you know what you are doing.
|
app.use([path,] function [, function...])
Mounts the middleware function
(s) at the path
. If path
is not specified, it defaults to “/”.
A route will match any path, which follows its path immediately with a “/
”.
For example: app.use('/apple', ...)
will match /apple, /apple/images,
/apple/images/news, and so on.
Mounting a middleware at a path
will cause the middleware function to be executed whenever the base of the requested path matches the path
.
Since path
defaults to “/”, middleware mounted without a path will be executed for every request to the app.
// this middleware will be executed for every request to the app
app.use(function (req, res, next) {
console.log('Time: %d', Date.now());
next();
})
Middleware functions are executed sequentially, therefore the order of middleware inclusion is important.
// this middleware will not allow the request to go beyond it
app.use(function(req, res, next) {
res.send('Hello World');
})
// requests will never reach this route
app.get('/', function (req, res) {
res.send('Welcome');
})
path
can be a string representing a path, a path pattern, a regular expression to match paths,
or an array of combinations thereof.
The middleware in the below are simple examples.
| Type | Example |
|---|---|
| Path |
|
| Path Pattern |
|
| Regular Expression |
|
| Array |
|
function
can be a middleware function, a series of middleware functions,
an array of middleware functions, or a combination of all of them.
Since router and app implement the middleware interface, you can use them
as you would any other middleware function.
| Usage | Example |
|---|---|
| Single Middleware | You can define and mount a middleware function locally.
A router is valid middleware.
An Express app is valid middleware.
|
| Series of Middleware |
You can specify more than one middleware function at the same mount path.
|
| Array |
Use an array to group middleware logically.
If you pass an array of middleware as the first or only middleware parameters, then you _must_ specify the mount path.
|
| Combination |
You can combine all the above ways of mounting middleware.
|
Following are some examples of using the express.static middleware in an Express app.
Serve static content for the app from the “public” directory in the application directory:
// GET /style.css etc
app.use(express.static(__dirname + '/public'));
Mount the middleware at “/static” to serve static content only when their request path is prefixed with “/static”:
// GET /static/style.css etc.
app.use('/static', express.static(__dirname + '/public'));
Disable logging for static content requests by loading the logger middleware after the static middleware:
app.use(express.static(__dirname + '/public'));
app.use(logger());
Serve static files from multiple directories, but give precedence to “./public” over the others:
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/files'));
app.use(express.static(__dirname + '/uploads'));
Request
The req
object represents the HTTP request and has properties for the
request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention,
the object is always referred to as req
(and the HTTP response is res
) but its actual name is determined
by the parameters to the callback function in which you’re working.
For example:
app.get('/user/:id', function(req, res){
res.send('user ' + req.params.id);
});
But you could just as well have:
app.get('/user/:id', function(request, response){
response.send('user ' + request.params.id);
});
Properties
req.app
This property holds a reference to the instance of the express application that is using the middleware.
If you follow the pattern in which you create a module that just exports a middleware
in order for requiring it in your main file, then the middleware can access the express instance via req.app
For example:
//index.js
app.get("/viewdirectory", require("./mymiddleware.js"))
//mymiddleware.js
module.exports = function (req, res) {
res.send("The views directory is " + req.app.get("views"));
});
req.baseUrl
The URL path on which a router instance was mounted. For example:
var greet = express.Router();
greet.get('/jp', function (req, res) {
console.log(req.baseUrl); // /greet
res.send('Konichiwa!');
});
app.use('/greet', greet); // load the router on '/greet'
Even if you use a path pattern or a set of path patterns to load the router,
the baseUrl
property returns the matched string, not the pattern(s). In the
following example, the greet
router is loaded on two path patterns.
app.use(['/gre+t', '/hel{2}o'], greet); // load the router on '/gre+t' and '/hel{2}o'
When a request is made to /greet/jp
, req.baseUrl
is “/greet”. When a request is
made to /hello/jp
, req.baseUrl
is “/hello”.
req.baseUrl
is similar to the mountpath property of the app
object,
except app.mountpath
returns the matched path pattern(s).
req.body
Contains key-value pairs of data submitted in the request body.
By default, it is undefined
, and is populated when you use body-parsing middleware such
as body-parser and multer.
This example shows how to use body-parsing middleware to populate req.body
.
var app = require('express')();
var bodyParser = require('body-parser');
var multer = require('multer');
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(multer()); // for parsing multipart/form-data
app.post('/', function (req, res) {
console.log(req.body);
res.json(req.body);
})
req.cookies
When using cookie-parser middleware, this property is an object that
contains cookies sent by the request. If the request contains no cookies, it defaults to {}
.
// Cookie: name=tj
req.cookies.name
// => "tj"
For more information, issues, or concerns, see cookie-parser.
req.fresh
Indicates whether the request is “fresh.” It is the opposite of req.stale
.
It is true if the cache-control
request header doesn’t have a no-cache
directive and any
of the following is true:
- The
if-modified-since
request header is specified andlast-modified
request header is equal to or eariler than themodified
response header. - The
if-none-match
request header is*
. - The
if-none-match
request header, after being parsed into its directives, does not match theetag
response header.
req.fresh
// => true
For more information, issues, or concerns, see fresh.
req.hostname
Contains the hostname from the “Host” HTTP header.
// Host: "example.com:3000"
req.hostname
// => "example.com"
req.ip
The remote IP address of the request.
If the trust proxy
is setting enabled, it is the upstream address;
see Express behind proxies for more information.
req.ip
// => "<IP_ADDRESS>"
req.ips
When the trust proxy
setting is true
, this property contains an array of
IP addresses specified in the “X-Forwarded-For” request header. Otherwise, it contains an empty array.
For example, if “X-Forwarded-For” is “client, proxy1, proxy2”, req.ips
would be
["client", "proxy1", "proxy2"]
, where “proxy2” is the furthest downstream.
For more information on the trust proxy
setting, see app.set.
req.originalUrl
This property is much like req.url; however, it retains the original request URL,
allowing you to rewrite req.url
freely for internal routing purposes. For example,
the “mounting” feature of app.use() will rewrite req.url
to strip the mount point.
// GET /search?q=something
req.originalUrl
// => "/search?q=something"
req.params
An object containing properties mapped to the named route “parameters”. For example, if you have the route /user/:name
, then the “name” property is available as req.params.name
. This object defaults to {}
.
// GET /user/tj
req.params.name
// => "tj"
When you use a regular expression for the route definition, capture groups are provided in the array using req.params[n]
, where n
is the nth capture group. This rule is applied to unnamed wild card matches with string routes such as /file/*
:
// GET /file/javascripts/jquery.js
req.params[0]
// => "javascripts/jquery.js"
req.path
Contains the path part of the request URL.
// example.com/users?sort=desc
req.path
// => "/users"
req.protocol
The request protocol string, “http” or “https” when requested with TLS. When the “trust proxy” setting trusts the socket address, the value of the “X-Forwarded-Proto” header (“http” or “https”) field will be trusted and used if present.
req.protocol
// => "http"
req.query
An object containing a property for each query string parameter in the route.
If there is no query string, it is the empty object, {}
.
// GET /search?q=tobi+ferret
req.query.q
// => "tobi ferret"
// GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse
req.query.order
// => "desc"
req.query.shoe.color
// => "blue"
req.query.shoe.type
// => "converse"
req.route
The currently-matched route, a string. For example:
app.get('/user/:id?', function userIdHandler(req, res) {
console.log(req.route);
res.send('GET');
})
Example output from the previous snippet:
{ path: '/user/:id?',
stack:
[ { handle: [Function: userIdHandler],
name: 'userIdHandler',
params: undefined,
path: undefined,
keys: [],
regexp: /^\/?$/i,
method: 'get' } ],
methods: { get: true } }
req.secure
A Boolean that is true if a TLS connection is established. Equivalent to:
'https' == req.protocol;
req.signedCookies
When using cookie-parser middleware, this property
contains signed cookies sent by the request, unsigned and ready for use. Signed cookies reside
in a different object to show developer intent; otherwise, a malicious attack could be placed on
req.cookie
values (which are easy to spoof). Note that signing a cookie does not make it “hidden”
or encrypted; but simply prevents tampering (because the secret used to sign is private).
If no signed cookies are sent, the property defaults to {}
.
// Cookie: user=tobi.CP7AWaXDfAKIRfH49dQzKJx7sKzzSoPq7/AcBBRVwlI3
req.signedCookies.user
// => "tobi"
For more information, issues, or concerns, see cookie-parser.
req.stale
Indicates whether the request is “stale,” and is the opposite of req.fresh
.
For more information, see req.fresh.
req.stale
// => true
req.subdomains
An array of subdomains in the domain name of the request.
// Host: "tobi.ferrets.example.com"
req.subdomains
// => ["ferrets", "tobi"]
req.xhr
A Boolean value that is true
if the request’s “X-Requested-With” header field is
“XMLHttpRequest”, indicating that the request was issued by a client library such as jQuery.
req.xhr
// => true
Methods
req.accepts(types)
Checks if the specified content types are acceptable, based on the request’s Accept
HTTP header field.
The method returns the best match, or if none of the specified content types is acceptable, returns
undefined
(in which case, the application should respond with 406 "Not Acceptable"
).
The type
value may be a single MIME type string (such as “application/json”),
an extension name such as “json”, a comma-delimited list, or an array. For a
list or array, the method returns the best match (if any).
// Accept: text/html
req.accepts('html');
// => "html"
// Accept: text/*, application/json
req.accepts('html');
// => "html"
req.accepts('text/html');
// => "text/html"
req.accepts('json, text');
// => "json"
req.accepts('application/json');
// => "application/json"
// Accept: text/*, application/json
req.accepts('image/png');
req.accepts('png');
// => undefined
// Accept: text/*;q=.5, application/json
req.accepts(['html', 'json']);
req.accepts('html, json');
// => "json"
For more information, or if you have issues or concerns, see accepts.
req.acceptsCharsets(charset [, ...])
Returns the first accepted charset of the specified character sets,
based on the request’s Accept-Charset
HTTP header field.
If none of the specified charsets is accepted, returns false
.
For more information, or if you have issues or concerns, see accepts.
req.acceptsEncodings(encoding [, ...])
Returns the first accepted encoding of the specified encodings,
based on the request’s Accept-Encoding
HTTP header field.
If none of the specified encodings is accepted, returns false
.
For more information, or if you have issues or concerns, see accepts.
req.acceptsLanguages(lang [, ...])
Returns the first accepted language of the specified languages,
based on the request’s Accept-Language
HTTP header field.
If none of the specified languages is accepted, returns false
.
For more information, or if you have issues or concerns, see accepts.
req.get(field)
Returns the specified HTTP request header field (case-insensitive match).
The Referrer
and Referer
fields are interchangeable.
req.get('Content-Type');
// => "text/plain"
req.get('content-type');
// => "text/plain"
req.get('Something');
// => undefined
Aliased as req.header(field)
.
req.is(type)
Returns true
if the incoming request’s “Content-Type” HTTP header field
matches the MIME type specified by the type
parameter.
Returns false
otherwise.
// With Content-Type: text/html; charset=utf-8
req.is('html');
req.is('text/html');
req.is('text/*');
// => true
// When Content-Type is application/json
req.is('json');
req.is('application/json');
req.is('application/*');
// => true
req.is('html');
// => false
For more information, or if you have issues or concerns, see type-is.
req.param(name [, defaultValue])
Deprecated. Use either req.params
, req.body
or req.query
, as applicable.
Return the value of param name
when present.
// ?name=tobi
req.param('name')
// => "tobi"
// POST name=tobi
req.param('name')
// => "tobi"
// /user/tobi for /user/:name
req.param('name')
// => "tobi"
Lookup is performed in the following order:
req.params
req.body
req.query
Optionally, you can specify defaultValue
to set a default value if the parameter is not found in any of the request objects.
Direct access to req.body
, req.params
, and req.query
should be favoured for clarity - unless you truly accept input from each object.
Body-parsing middleware must be loaded for req.param()
to work predictably. Refer req.body for details.
Response
The res
object represents the HTTP response that an Express app sends when it gets an HTTP request.
In this documentation and by convention,
the object is always referred to as res
(and the HTTP request is req
) but its actual name is determined
by the parameters to the callback function in which you’re working.
For example:
app.get('/user/:id', function(req, res){
res.send('user ' + req.params.id);
});
But you could just as well have:
app.get('/user/:id', function(request, response){
response.send('user ' + request.params.id);
});
Properties
res.app
This property holds a reference to the instance of the express application that is using the middleware.
res.app
is identical to the req.app property in the request object.
res.headersSent
Boolean property that indicates if the app sent HTTP headers for the response.
app.get('/', function (req, res) {
console.log(res.headersSent); // false
res.send('OK');
console.log(res.headersSent); // true
})
res.locals
An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals.
This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
app.use(function(req, res, next){
res.locals.user = req.user;
res.locals.authenticated = ! req.user.anonymous;
next();
});
Methods
res.append(field [, value])
res.append()
is supported by Express v4.11.0+
Appends the specified value
to the HTTP response header field
. If the header is not already set,
it creates the header with the specified value. The value
parameter can be a string or an array.
Note: calling res.set()
after res.append()
will reset the previously-set header value.
res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
res.append('Warning', '199 Miscellaneous warning');
res.attachment([filename])
Sets the HTTP response Content-Disposition
header field to “attachment”. If a filename
is given,
then it sets the Content-Type based on the extension name via res.type()
,
and sets the Content-Disposition
“filename=” parameter.
res.attachment();
// Content-Disposition: attachment
res.attachment('path/to/logo.png');
// Content-Disposition: attachment; filename="logo.png"
// Content-Type: image/png
res.cookie(name, value [, options])
Sets cookie name
to value
. The value
parameter may be a string or object converted to JSON.
The options
parameter is an object that can have the following properties.
| Property | Type | Description |
|---|---|---|
domain |
String | Domain name for the cookie. Defaults to the domain name of the app. |
expires |
Date | Expiry date of the cookie in GMT. If not specified or set to 0, creates a session cookie. |
httpOnly |
Boolean | Flags the cookie to be accessible only by the web server. |
maxAge |
String | Convenient option for setting the expiry time relative to the current time in milliseconds. |
path |
String | Path for the cookie. Defaults to “/”. |
secure |
Boolean | Marks the cookie to be used with HTTPS only. |
signed |
Boolean | Indicates if the cookie should be signed. |
All res.cookie()
does is set the HTTP Set-Cookie
header with the options provided.
Any option not specified defaults to the value stated in RFC 6265.
For example:
res.cookie('name', 'tobi', { domain: '.example.com', path: '/admin', secure: true });
res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
The maxAge
option is a convenience option for setting “expires” relative to the current time in milliseconds.
The following is equivalent to the second example above.
res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
You can pass an object as the value
parameter; it is then serialized as JSON and parsed by bodyParser()
middleware.
res.cookie('cart', { items: [1,2,3] });
res.cookie('cart', { items: [1,2,3] }, { maxAge: 900000 });
When using cookie-parser middleware, this method also
supports signed cookies. Simply include the signed
option set to true
.
Then res.cookie()
will use the secret passed to cookieParser(secret)
to sign the value.
res.cookie('name', 'tobi', { signed: true });
Later you may access this value through the req.signedCookie object.
res.clearCookie(name [, options])
Clears the cookie specified by name
. For details about the options
object, see res.cookie().
res.cookie('name', 'tobi', { path: '/admin' });
res.clearCookie('name', { path: '/admin' });
res.download(path [, filename] [, fn])
Transfers the file at path
as an “attachment”. Typically, browsers will prompt the user for download.
By default, the Content-Disposition
header “filename=” parameter is path
(this typically appears in the brower dialog).
Override this default with the filename
parameter.
When an error ocurrs or transfer is complete, the method calls the optional callback function fn
.
This method uses res.sendFile() to transfer the file.
res.download('/report-12345.pdf');
res.download('/report-12345.pdf', 'report.pdf');
res.download('/report-12345.pdf', 'report.pdf', function(err){
if (err) {
// Handle error, but keep in mind the response may be partially-sent
// so check res.headersSent
} else {
// decrement a download credit, etc.
}
});
res.end([data] [, encoding])
Ends the response process. Inherited from Node’s http.ServerResponse.
Use to quickly end the response without any data. If you need to respond with data, instead use methods such as res.send() and res.json().
res.end();
res.status(404).end();
res.format(object)
Performs content-negotiation on the Accept
HTTP header on the request object, when present.
It uses req.accepts() to select a handler for the request, based on the acceptable
types ordered by their quality values. If the header is not specified, the first callback is invoked.
When no match is found, the server responds with 406 “Not Acceptable”, or invokes the default
callback.
The Content-Type
response header is set when a callback is selected. However, you may alter
this within the callback using methods such as res.set()
or res.type()
.
The following example would respond with { "message": "hey" }
when the Accept
header field is set
to “application/json” or “*/json” (however if it is “*/*”, then the response will be “hey”).
res.format({
'text/plain': function(){
res.send('hey');
},
'text/html': function(){
res.send('<p>hey</p>');
},
'application/json': function(){
res.send({ message: 'hey' });
},
'default': function() {
// log the request and respond with 406
res.status(406).send('Not Acceptable');
}
});
In addition to canonicalized MIME types, you may also use extension names mapped to these types for a slightly less verbose implementation:
res.format({
text: function(){
res.send('hey');
},
html: function(){
res.send('<p>hey</p>');
},
json: function(){
res.send({ message: 'hey' });
}
});
res.get(field)
Returns the HTTP response header specified by field
.
The match is case-insensitive.
res.get('Content-Type');
// => "text/plain"
res.json([body])
Sends a JSON response. This method is identical to res.send()
with an object or array as the parameter.
However, you can use it to convert other values to JSON, such as null
, and undefined
.
(although these are technically not valid JSON).
res.json(null)
res.json({ user: 'tobi' })
res.status(500).json({ error: 'message' })
res.jsonp([body])
Sends a JSON response with JSONP support. This method is identical to res.json()
,
except that it opts-in to JSONP callback support.
res.jsonp(null)
// => null
res.jsonp({ user: 'tobi' })
// => { "user": "tobi" }
res.status(500).jsonp({ error: 'message' })
// => { "error": "message" }
By default, the JSONP callback name is simply callback
. Override this with the
jsonp callback name setting.
The following are some examples of JSONP responses using the same code:
// ?callback=foo
res.jsonp({ user: 'tobi' })
// => foo({ "user": "tobi" })
app.set('jsonp callback name', 'cb');
// ?cb=foo
res.status(500).jsonp({ error: 'message' })
// => foo({ "error": "message" })
res.links(links)
Joins the links
provided as properties of the parameter to populate the response’s
Link
HTTP header field.
res.links({
next: 'http://api.example.com/users?page=2',
last: 'http://api.example.com/users?page=5'
});
yields:
Link: <http://api.example.com/users?page=2>; rel="next",
<http://api.example.com/users?page=5>; rel="last"
res.location(path)
Sets the response Location
HTTP header field based on the specified path
parameter; for example:
res.location('/foo/bar');
res.location('foo/bar');
res.location('http://example.com');
res.location('../login');
res.location('back');
The path
parameter can be any of the paths as for res.redirect():
an absolute URL, a path relative to application root, a path relative to current mount
path, and so on.
For example, if your application is mounted at /blog
, the following would set the
location
header to /blog/admin
:
res.location('admin')
res.redirect([status,] path)
Express passes the specified URL string as-is to the browser in the Location
header,
without any validation or manipulation, except in case of back
.
Browsers take the responsibility of deriving the intended URL from the current URL
or the referring URL, and the URL specified in the Location
header; and redirect the user accordingly.
Redirects to the URL dervied from the specified path
, with specified
HTTP status code status
.
If you don’t specify status
, the status code defaults to “302 “Found”.
res.redirect('/foo/bar');
res.redirect('http://example.com');
res.redirect(301, 'http://example.com');
res.redirect('../login');
Redirects can be a fully-qualified URL for redirecting to a different site:
res.redirect('http://google.com');
Redirects can be relative to the root of the host name. For example, if the
application is on http://example.com/admin/post/new
, the following
would redirect to the URL http://example.com/admin
:
res.redirect('/admin');
Redirects can be relative to the current URL. For example,
from http://example.com/blog/admin/
(notice the trailing slash), the following
would redirect to the URL http://example.com/blog/admin/post/new
.
res.redirect('post/new');
Redirecting to post/new
from http://example.com/blog/admin
(no trailing slash),
will redirect to http://example.com/blog/post/new
.
If you found the above behavior confusing, think of path segments as directories (with trailing slashes) and files, it will start to make sense.
Path-relative redirects are also possible. If you were on
http://example.com/admin/post/new
, the following would redirect to
http//example.com/admin/post
:
res.redirect('..');
A back
redirection redirects the request back to the referer,
defaulting to /
when the referer is missing.
res.redirect('back');
res.render(view [, locals] [, callback])
Renders a view
and sends the rendered HTML string to the client.
Optional parameters:
locals
, an object whose properties define local variables for the view.callback
, a callback function. If provided, the method returns both the possible error and rendered string, but does not perform an automated response. When an error occurs, the method invokesnext(err)
internally.
The local variable cache
enables view caching. Set it to true
,
to cache the view during development; view caching is enabled in production by default.
// send the rendered view to the client
res.render('index');
// if a callback is specified, the rendered HTML string has to be sent explicitly
res.render('index', function(err, html) {
res.send(html);
});
// pass a local variable to the view
res.render('user', { name: 'Tobi' }, function(err, html) {
// ...
});
res.send([body])
Sends the HTTP response.
The body
parameter can be a Buffer
object, a String
, an object, or an Array
.
For example:
res.send(new Buffer('whoop'));
res.send({ some: 'json' });
res.send('<p>some html</p>');
res.status(404).send('Sorry, we cannot find that!');
res.status(500).send({ error: 'something blew up' });
This method performs many useful tasks for simple non-streaming responses:
For example, it automatically assigns the Content-Length
HTTP response header field
(unless previously defined) and provides automatic HEAD and HTTP cache freshness support.
When the parameter is a Buffer
object, the method sets the Content-Type
response header field to “application/octet-stream”, unless previously defined as shown below:
res.set('Content-Type', 'text/html');
res.send(new Buffer('<p>some html</p>'));
When the parameter is a String
, the method sets the Content-Type
to “text/html”:
res.send('<p>some html</p>');
When the parameter is an Array
or Object
, Express responds with the JSON representation:
res.send({ user: 'tobi' });
res.send([1,2,3]);
res.sendFile(path [, options] [, fn])
res.sendFile()
is supported from Express v4.8.0 onwards
Transfers the file at the given path
. Sets the Content-Type
response HTTP header field
based on the filename’s extension. Unless the root
option is set in
the options object, path
must be an absolute path of the file.
The details of the options
object is listed in the following table.
| Property | Description | Default | Availability |
|---|---|---|---|
maxAge |
Sets the max-age property of the Cache-Control header in milliseconds or a string in ms format |
0 | |
root |
Root directory for relative filenames. | ||
lastModified |
Sets the Last-Modified header to the last modified date of the file on the OS. Set false to disable it. |
Enabled | 4.9.0+ |
headers |
Object containing HTTP headers to serve with the file. | ||
dotfiles |
Option for serving dotfiles. Possible values are “allow”, “deny”, “ignore”. | “ignore” |
The method invokes the callback function fn(err)
when the transfer is complete
or when an error occurs. If the callback function is specified and an error occurs,
the callback function must explicitly handle the response process either by
ending the request-response cycle, or by passing control to the next route.
Here is an example of using res.sendFile
with all its arguments.
app.get('/file/:name', function (req, res, next) {
var options = {
root: __dirname + '/public/',
dotfiles: 'deny',
headers: {
'x-timestamp': Date.now(),
'x-sent': true
}
};
var fileName = req.params.name;
res.sendFile(fileName, options, function (err) {
if (err) {
console.log(err);
res.status(err.status).end();
}
else {
console.log('Sent:', fileName);
}
});
})
res.sendFile
provides fine-grained support for file serving as illustrated in the following example:
app.get('/user/:uid/photos/:file', function(req, res){
var uid = req.params.uid
, file = req.params.file;
req.user.mayViewFilesFrom(uid, function(yes){
if (yes) {
res.sendFile('/uploads/' + uid + '/' + file);
} else {
res.status(403).send('Sorry! you cant see that.');
}
});
});
For more information, or if you have issues or concerns, see send.
res.sendStatus(statusCode)
Set the response HTTP status code to statusCode
and send its string representation as the response body.
res.sendStatus(200); // equivalent to res.status(200).send('OK')
res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
If an unsupported status code is specified, the HTTP status is still set to statusCode
and the string version of the code is sent as the response body.
res.sendStatus(2000); // equivalent to res.status(2000).send('2000')
res.set(field [, value])
Sets the response’s HTTP header field
to value
.
To set multiple fields at once, pass an object as the parameter.
res.set('Content-Type', 'text/plain');
res.set({
'Content-Type': 'text/plain',
'Content-Length': '123',
'ETag': '12345'
})
Aliased as res.header(field [, value])
.
res.status(code)
Use this method to set the HTTP status for the response. It is a chainable alias of Node’s response.statusCode.
res.status(403).end();
res.status(400).send('Bad Request');
res.status(404).sendFile('/absolute/path/to/404.png');
res.type(type)
Sets the Content-Type
HTTP header to the MIME type as determined by
mime.lookup() for the specified type
.
If type
contains the “/” character, then it sets the Content-Type
to type
.
res.type('.html'); // => 'text/html'
res.type('html'); // => 'text/html'
res.type('json'); // => 'application/json'
res.type('application/json'); // => 'application/json'
res.type('png'); // => image/png:
res.vary(field)
Adds the field to the Vary
response header, if it is not there already.
res.vary('User-Agent').render('docs');
Router
A router
object is an isolated instance of middleware and routes. You can think of it
as a “mini-application,” capable only of performing middleware and routing
functions. Every Express application has a built-in app router.
A router behaves like middleware itself, so you can use it as an argument to app.use() or as the argument to another router’s use() method.
The top-level express
object has a Router()
function that creates a new router
object.
Router([options])
Create a new router as follows:
var router = express.Router([options]);
The optional options
parameter specifies the behavior of the router.
| Property | Description | Default | Availability |
|---|---|---|---|
caseSensitive |
Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same. | |
mergeParams |
Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. |
false |
4.5.0+ |
strict |
Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router. |
You can add middleware and HTTP method routes (such as get
, put
, post
, and
so on) to router
just like an application.
// invoked for any requests passed to this router
router.use(function(req, res, next) {
// .. some logic here .. like any other middleware
next();
});
// will handle any request that ends in /events
// depends on where the router is "use()'d"
router.get('/events', function(req, res, next) {
// ..
});
You can then use a router for a particular root URL in this way separating your routes into files or even mini-apps.
// only requests to /calendar/* will be sent to our "router"
app.use('/calendar', router);
Methods
router.all(path, [callback, ...] callback)
This method functions just like the router.METHOD()
methods, except that it matches all HTTP verbs.
This method is extremely useful for
mapping “global” logic for specific path prefixes or arbitrary matches.
For example, if you placed the following route at the top of all other
route definitions, it would require that all routes from that point on
would require authentication, and automatically load a user. Keep in mind
that these callbacks do not have to act as end points; loadUser
can perform a task, then call next()
to continue matching subsequent
routes.
router.all('*', requireAuthentication, loadUser);
Or the equivalent:
router.all('*', requireAuthentication)
router.all('*', loadUser);
Another example of this is white-listed “global” functionality. Here the example is much like before, but it only restricts paths prefixed with “/api”:
router.all('/api/*', requireAuthentication);
router.METHOD(path, [callback, ...] callback)
The router.METHOD()
methods provide the routing functionality in Express,
where METHOD is one of the HTTP methods, such as GET, PUT, POST, and so on,
in lowercase. Thus, the actual methods are router.get()
, router.post()
,
router.put()
, and so on.
You can provide multiple callbacks, and all are treated equally, and behave just
like middleware, except that these callbacks may invoke next('route')
to bypass the remaining route callback(s). You can use this mechanism to perform
pre-conditions on a route then pass control to subsequent routes when there is no
reason to proceed with the route matched.
The following snippet illustrates the most simple route definition possible. Express translates the path strings to regular expressions, used internally to match incoming requests. Query strings are not considered when performing these matches, for example “GET /” would match the following route, as would “GET /?name=tobi”.
router.get('/', function(req, res){
res.send('hello world');
});
You can also use regular expressions—useful if you have very specific constraints, for example the following would match “GET /commits/71dbb9c” as well as “GET /commits/71dbb9c..4c084f9”.
router.get(/^\/commits\/(\w+)(?:\.\.(\w+))?$/, function(req, res){
var from = req.params[0];
var to = req.params[1] || 'HEAD';
res.send('commit range ' + from + '..' + to);
});
router.param([name,] callback)
Add callback triggers to route paramters, where name
is the name of the parameter or an array of them, and function
is the callback function. The parameters of the callback function are the request object, the response object, the next middleware, and the value of the parameter, in that order.
For example, when :user
is present in a route path, you may map user loading logic to automatically provide req.user
to the route, or perform validations on the parameter input.
router.param('user', function(req, res, next, id) {
// try to get the user details from the User model and attach it to the request object
User.find(id, function(err, user) {
if (err) {
next(err);
} else if (user) {
req.user = user;
next();
} else {
next(new Error('failed to load user'));
}
});
});
Param callback functions are local to the router on which they are defined. They are not inherited by mounted apps or routers. Hence, param callbacks defined on router
will be triggered only by route parameters defined on router
routes.
A param callback will be called only once in a request-response cycle, even if the parameter is matched in multiple routes, as shown in the following example.
router.param('id', function (req, res, next, id) {
console.log('CALLED ONLY ONCE');
next();
})
router.get('/user/:id', function (req, res, next) {
console.log('although this matches');
next();
});
router.get('/user/:id', function (req, res) {
console.log('and this matches too');
res.end();
});
router.param(callback)
is deprecated as of v4.11.0.
By passing only a callback function, you can alter the router.param()
API. For example the express-params defines the following callback which allows you to restrict parameters to a given regular expression.
The code in the next section can be migrated using the following, without the use of router.param(callback)
:
<pre class="language-javascript">
router.get(‘/user/:id([0-9]+)’, function(req, res){
res.send(‘user ‘ + req.params.id);
});
router.get(‘/range/:range(\w+..\w+)’, function(req, res){ var range = req.params.range.split(‘..’); res.send(‘from ‘ + range[0] + ‘ to ‘ + range[1]); }); </pre>
router.param(function(name, fn) {
if (fn instanceof RegExp) {
return function(req, res, next, val) {
var captures;
if (captures = fn.exec(String(val))) {
req.params[name] = captures;
next();
} else {
next('route');
}
}
}
});
The method could now be used to effectively validate parameters (and optionally parse them to provide capture groups):
// validation rule for id: should be one or more digits
router.param('id', /^\d+$/);
router.get('/user/:id', function(req, res) {
res.send('user ' + req.params.id);
});
// validation rule for range: should start with one more alphanumeric characters, followed by two dots, and end with one more alphanumeric characters
router.param('range', /^(\w+)\.\.(\w+)?$/);
router.get('/range/:range', function(req, res) {
var range = req.params.range;
res.send('from ' + range[1] + ' to ' + range[2]);
});
The router.use()
method also supports named parameters so that your mount points
for other routers can benefit from preloading using named parameters.
router.route(path)
Returns an instance of a single route which you can then use to handle HTTP verbs
with optional middleware. Use router.route()
to avoid duplicate route naming and
thus typo errors.
Building on the router.param()
example above, the following code shows how to use
router.route()
to specify various HTTP method handlers.
var router = express.Router();
router.param('user_id', function(req, res, next, id) {
// sample user, would actually fetch from DB, etc...
req.user = {
id: id,
name: 'TJ'
};
next();
});
router.route('/users/:user_id')
.all(function(req, res, next) {
// runs for all HTTP verbs first
// think of it as route specific middleware!
next();
})
.get(function(req, res, next) {
res.json(req.user);
})
.put(function(req, res, next) {
// just an example of maybe updating the user
req.user.name = req.params.name;
// save user ... etc
res.json(req.user);
})
.post(function(req, res, next) {
next(new Error('not implemented'));
})
.delete(function(req, res, next) {
next(new Error('not implemented'));
})
This apporach re-uses the single ‘/users/:user_id’ path and add handlers for various HTTP methods.
router.use([path], [function, ...] function)
Uses the given middleware function
, with optional mount path path
, that defaults to “/”.
This method is similar to app.use(). A simple example and usecase is described below. See app.use() for more information.
Middleware is like a plumbing pipe, requests start at the first middleware you define and work their way “down” the middleware stack processing for each path they match.
var express = require('express');
var app = express();
var router = express.Router();
// simple logger for this router's requests
// all requests to this router will first hit this middleware
router.use(function(req, res, next) {
console.log('%s %s %s', req.method, req.url, req.path);
next();
});
// this will only be invoked if the path starts with /bar from the mount point
router.use('/bar', function(req, res, next) {
// ... maybe some additional /bar logging ...
next();
});
// always invoked
router.use(function(req, res, next) {
res.send('Hello World');
});
app.use('/foo', router);
app.listen(3000);
The “mount” path is stripped and is not visible to the middleware function
.
The main effect of this feature is that mounted middleware may operate without
code changes regardless of its “prefix” pathname.
The order in which you define middleware with router.use()
is very important.
They are invoked sequentially, thus the order defines middleware precedence. For example,
usually a logger is the very first middleware you would use, so every request is logged.
var logger = require('morgan');
router.use(logger());
router.use(express.static(__dirname + '/public'));
router.use(function(req, res){
res.send('Hello');
});
Now suppose you wanted to ignore logging requests for static files, but to continue
logging routes and middleware defined after logger()
. You would simply move static()
above:
router.use(express.static(__dirname + '/public'));
router.use(logger());
router.use(function(req, res){
res.send('Hello');
});
Another concrete example is serving files from multiple directories, giving precedence to “./public” over the others:
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/files'));
app.use(express.static(__dirname + '/uploads'));
The router.use()
method also supports named parameters so that your mount points
for other routers can benefit from preloading using named parameters.


--- layout: default permalink: team.html ---
We are a group of passionate students who thrive for open data. Please reach out if you have any questions!


GNOME-POWER-MANAGER
Section: (1)Updated: 29 March,2006
Index Return to Main Contents
NAME
gnome-power-manager - gnome power manager userspace daemonSYNOPSIS
gnome-power-manager [ --verbose ] [ --debug ] [ --help ]
DESCRIPTION
This manual page documents briefly the gnome-power-manager command.
gnome-power-manager is the backend program of the GNOME power management infrastructure providing a complete and integrated solution to power management under the GNOME desktop environment.
It supports features such as suspending, hibernating, screen blanking, cpu frequency switching and more in one small neat package.
OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below.
- --help
- Show summary of options.
- --verbose
- Show extra debugging.
- --no-daemon
- Do not detach gnome-power-manager into the background so that error messages will be displayed on console.
- --debug
- Only show specific debugging options. Useful for developers only.
SEE ALSO
gnome-power-preferences (1).
The programs are documented fully on http://gnome.org/projects/gnome-power-manager/ .
AUTHOR
This manual page was written by Oliver Grawert<EMAIL_ADDRESS>for the Debian system and updated by Ow Mun Heng<EMAIL_ADDRESS>Index
This document was created by man2html, using the manual pages.
Time: 05:29:04 GMT, December 24, 2015


library(kwb.qmra)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(knitr)
## Warning: package 'knitr' was built under R version 3.4.3
library(ggplot2)
library(ggrepel)
## Warning: package 'ggrepel' was built under R version 3.4.3
2.1 Download
dr.db <- kwb.qmra::dr.db_download()
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_integer(),
## Agent = col_character(),
## `Best fit model*` = col_character(),
## `Optimized parameter(s)` = col_character(),
## `LD50/ID50` = col_double(),
## `Host type` = col_character(),
## `Agent strain` = col_character(),
## Route = col_character(),
## `# of doses` = col_integer(),
## `Dose units` = col_character(),
## Response = col_character(),
## Reference = col_character(),
## Link = col_character(),
## PathogenGroup = col_character(),
## PathogenName = col_character(),
## k = col_double(),
## alpha = col_double(),
## N50 = col_double(),
## PathogenID = col_integer()
## )
Database:
dr.db2 <- dr.db %>% dplyr::select(PathogenGroup,
PathogenName,
`Agent strain`,
`Best fit model*`,
`Optimized parameter(s)`,
`LD50/ID50`,
`Host type`,
Route,
`Dose units`,
Response,
Reference) %>%
dplyr::arrange(PathogenGroup, PathogenName)
caption <- "Table 1: Best-fit dose-response parameters ([QMRAwiki, 2016](http://qmrawiki.canr.msu.edu/index.php/?title=Table_of_Recommended_Best-Fit_Parameters))"
knitr::kable(dr.db2,caption = caption )
| PathogenGroup | PathogenName | Agent strain | Best fit model* | Optimized parameter(s) | LD50/ID50 | Host type | Route | Dose units | Response | Reference |
|---|---|---|---|---|---|---|---|---|---|---|
| Bacteria | Bacillus anthracis | Vollum | exponential | k = 1.65E-05 | 4.20e+04 | guinea pig | inhalation | spores | death | Druett 1953 |
| Bacteria | Burkholderia pseudomallei | KHW,316c | beta-Poisson | a = 3.28E-01 , N50 = 5.43E+03 | 5.43e+03 | C57BL/6 mice and diabetic rat | intranasal,intraperitoneal | CFU | death | Liu, Koo et al. 2002 and Brett and Woods 1996 |
| Bacteria | Campylobacter jejuni and Campylobacter coli | strain A3249 | beta-Poisson | a= 1.44E-01 , N50 = 8.9E+02 | 8.90e+02 | human | oral (in milk) | CFU | infection | Black et al 1988 |
| Bacteria | Coxiella burnetii | phase I Ohio | beta-Poisson | a= 3.57E-01 , N50 = 4.93E+08 | 4.93e+08 | C57BL/1OScN mice | intraperitoneal | PFU | death | Williams et al, 1982 |
| Bacteria | Escherichia coli | EIEC 1624 | beta-Poisson | a = 1.55E-01 , N50 = 2.11E+06 | 2.11e+06 | human | oral (in milk) | CFU | positive stool isolation | DuPont et al. (1971) |
| Bacteria | Escherichia coli enterohemorrhagic (EHEC) | EHEC O157:H7, strain 86-24 | exponential | k=2.18E-04 | 3.18e+03 | pig | oral (in food) | CFU | shedding in feces | Cornick & Helgerson (2004) |
| Bacteria | Francisella tularensis | SCHU S-4 | exponential | k = 4.73E-02 | 1.46e+01 | monkeys | inhalation | CFU | death | Day and Berendt, 1972 |
| Bacteria | Legionella pneumophila | Philadelphia 1 | exponential | k = 5.99E-02 | 1.16e+01 | guinea pig | inhalation | CFU | infection | Muller et al. (1983) |
| Bacteria | Listeria monocytogenes (Death as response) | F5817 | exponential | k = 1.15E-05 | 6.05e+04 | C57B1/6J mice | oral | CFU | death | Golnazarian, Donnelly et al. 1989 |
| Bacteria | Listeria monocytogenes (Infection) | F5817 | beta-Poisson | a = 2.53E-01 , N50 = 2.77E+02 | 2.77e+02 | C57Bl/6J mice | oral | CFU | infection | Golnazarian |
| Bacteria | Listeria monocytogenes (Stillbirths) | NA | beta-Poisson | a = 4.22E-02 , N50 = 1.78E+09 | 1.78e+09 | pooled | oral | CFU | stillbirths | Smith, Williams2007 |
| Bacteria | Mycobacterium avium | sub sp. Paratuberculosis Bovine | exponential | k = 6.93E-04 | 1.00e+03 | deer | oral | CFU | infection | O’Brien et al(1976) |
| Bacteria | Pseudomonas aeruginosa (bacterimia) | ATCC 19660 | exponential | k = 1.05E-04 | 6.61e+03 | Swiss webster mice (5day old) | injected in eyelids | CFU | death | Hazlett, Rosen et al. 1978 |
| Bacteria | Pseudomonas aeruginosa (Contact lens) | NA | beta-Poisson | a = 1.9E-01 , N50 = 1.85E+04 | 1.85e+04 | white rabbit | contact lens | CFU | corneal ulceration | Lawin-Brussel et al. (1993) |
| Bacteria | Rickettsia rickettsi | R1 and Sheila Smith | beta-Poisson | a= 7.77E-01 , N50 = 2.13E+01 | 2.13e+01 | Pooled data | NA | CFU | morbidity | Saslaw and Carlisle 1966 and Dupont, Hornick et al. 1973 |
| Bacteria | Salmonella anatum | strain I | beta-Poisson | a= 3.18E-01 , N50 = 3.71E+04 | 3.71e+04 | human | oral, with eggnog | CFU | positive stool culture | McCullough and Elsele,1951 |
| Bacteria | Salmonella meleagridis | strain I | beta-Poisson | a= 3.89E-01 , N50 = 1.68E+04 | 1.68e+04 | human | oral, with eggnog | CFU | infection | McCullough and Eisele 1951,2 |
| Bacteria | Salmonella nontyphoid | strain 216 and 219 | beta-Poisson | a= 2.1E-01 , N50 = 4.98E+01 | 4.98e+01 | mice | intraperitoneal | CFU | death | Meynell and Meynell,1958 |
| Bacteria | Salmonella serotype newport | Salmonella newport | exponential | k = 3.97E-06 | 1.74e+05 | human | oral | CFU | infection | McCullough and Elsele,1951 |
| Bacteria | Salmonella Typhi | Quailes | beta-Poisson | a = 1.75E-01 , N50 = 1.11E+06 | 1.11e+06 | human | oral, in milk | CFU | disease | Hornick et al. (1966),Hornick et al. (1970) |
| Bacteria | Shigella | 2a (strain 2457T) | beta-Poisson | a= 2.65E-01 , N50 = 1.48E+03 | 1.48e+03 | human | oral (in milk) | CFU | positive stool isolation | DuPont et al. (1972b) |
| Bacteria | Staphylococcus aureus | NA | exponential | k = 7.64E-08 | 9.08e+06 | human | subcutaneous | CFU/cm2 | infection | Rose and Haas 1999 |
| Bacteria | Vibrio cholerae | Inaba 569B | beta-Poisson | a= 2.50E-01 , N50 = 2.43E+02 | 2.43e+02 | human | oral (with NaHCO3) | CFU | infection | Hornick et al., (1971) |
| Bacteria | Yersinia pestis | CO92 | exponential | k = 1.63E-03 | 4.26e+02 | mice | intranasal | CFU | death | Lathem et al. 2005 |
| Protozoa | Cryptosporidium parvum and Cryptosporidium hominis | TAMU isolate | exponential | k = 5.72E-02 | 1.21e+01 | human | oral | oocysts | infection | Messner et al. 2001 |
| Protozoa | Endamoeba coli | From an infected human | beta-Poisson | a = 1.01E-01 , N50 = 3.41E+02 | 3.41e+02 | human | oral | Cysts | infection | Rendtorff 1954 |
| Protozoa | Giardia duodenalis | From an infected human | exponential | k = 1.99E-02 | 3.48e+01 | human | oral | Cysts | infection | Rendtorff 1954 |
| Protozoa | Naegleria fowleri | LEE strain | exponential | k = 3.42E-07 | 2.03e+06 | mice | intravenous | no of trophozoites | death | Adams et al. 1976 & Haggerty and John 1978 |
| Viruses | Adenovirus | type 4 | exponential | k = 6.07E-01 | 1.14e+00 | human | inhalation | TCID50 | infection | Couch, Cate et al. 1966 |
| Viruses | Echovirus | strain 12 | beta-Poisson | a = 1.06E+00 , N50 = 9.22E+02 | 9.22e+02 | human | oral | PFU | infection | Schiff et al.,1984 |
| Viruses | Enteroviruses | porcine, PE7-05i | exponential | k = 3.74E-03 | 1.85e+02 | pig | oral | PFU | infection | Cliver, 1981 |
| Viruses | Influenza | H1N1,A/California/10/78 attenuated strain, H3N2,A/Washington/897/80 attenuated strain | beta-Poisson | a = 5.81E-01 , N50 =9.45E+05 | 9.45e+05 | human | intranasal | TCID50 | infection | Murphy et al., 1984 & Murphy et al., 1985 |
| Viruses | Lassa virus | Josiah strain | exponential | k = 2.95E+00 | 2.35e-01 | guinea pig | subcutaneous | PFU | death | Jahrling et al., 1982 |
| Viruses | Poliovirus | type 1,attenuated | exponential | k = 4.91E-01 | 1.41e+00 | human | oral (capsule) | PD50 (mouse paralytic doses) | alimentary infection | Koprowski |
| Viruses | Rhinovirus | type 39 | beta-Poisson | a = 2.21E-01 , N50 = 1.81E+00 | 1.81e+00 | human | intranasal | TCID50 doses | infection | Hendley et al., 1972 |
| Viruses | Rotavirus | CJN strain (unpassaged) | beta-Poisson | a = 2.53E-01 , N50 = 6.17E+00 | 6.17e+00 | human | oral | FFU | infection | Ward et al, 1986 |
| Viruses | SARS | rSARS-CoV | exponential | k = 2.46E-03 | 2.82e+02 | mice hACE-2 and A/J | intranasal | PFU | death | DeDiego et al., 2008 & De Albuquerque et al., 2006 |
#DT::datatable(doseresponse, caption = caption)
Dose response for all microbial parameters:
dr.model <- kwb.qmra::dr.db_model(dr.db = dr.db)
ggplot( dr.model, aes(x = dose,
y = infectionProbability,
col = PathogenGroup)) +
geom_point() +
scale_x_log10() +
theme_bw()
Dose for all microbial parameters with 50% infection probability


Facts About Oranges has the largest database of orange facts of any internet company.
We are not owned by any large fruit cartels and never will be!*
*Pending acquisition offer
Our facts are served via CDN and require no backend infrastructure! Your power bill will love us.
Sign up for updates, and we'll send you facts 1000 times a day to your inbox.


We aim to provide a graphical representation . and their dangers they pose on the earth and our solar system. As well as other meaningful information on asteroids. View us on GitHub


| Methods' Summary |
| getName |
Unique ASCII name to identify a module. This name is used
to get its localized name for menus, dialogs etc. The behavior
is undefined for TransliterationType::CASCADE
modules.
|
| getType |
Return the attribute(s) associated with this transliterator
object, as defined in TransliterationType. The
value is determined by the transliteration modules. For example,
for UPPERCASE_LOWERCASE, a ONE_TO_ONE is returned, for
IGNORE_CASE, IGNORE is returned.
|
| loadModule |
Load instance of predefined module - old style method.
|
| loadModuleNew |
Load a sequence of instances of predefined modules - supersedes
method XTransliteration::loadModule().
|
| loadModuleByImplName |
Load instance of UNO registered module.
|
| loadModulesByImplNames |
Load a sequence of instances of transliteration modules.
Output of one module is feeded as input to the next module in
the sequence. The object created by this call has
TransliterationType CASCADE and IGNORE types.
|
| getAvailableModules |
List the available transliteration modules for a given locale.
It can be filtered based on its type.
|
| transliterate |
Transliterate a substring. This method can be called if the
object doesn't have TransliterationType IGNORE
attribute.
|
| folding |
[ DEPRECATED ]
|
| equals |
Match two substrings and find if they are equivalent as per this
transliteration.
|
| transliterateRange |
Transliterate one set of characters to another.
|
| compareSubstring |
Compare 2 substrings as per this transliteration. It translates both
substrings before comparing them.
|
| compareString |
Compare 2 strings as per this transliteration. It translates both
strings before comparing them.
|
| Methods' Details |
getName
- Description
- Unique ASCII name to identify a module. This name is used
to get its localized name for menus, dialogs etc. The behavior
is undefined for TransliterationType::CASCADE
modules.
|
|
getType
- Description
- Return the attribute(s) associated with this transliterator
object, as defined in TransliterationType. The
value is determined by the transliteration modules. For example,
for UPPERCASE_LOWERCASE, a ONE_TO_ONE is returned, for
IGNORE_CASE, IGNORE is returned.
|
|
loadModule
- Description
- Load instance of predefined module - old style method.
|
|
| loadModuleNew
|
loadModuleByImplName
| void |
| loadModuleByImplName( |
[in] string |
aImplName, |
| [in] ::com::sun::star::lang::Locale |
aLocale ); |
- Description
- Load instance of UNO registered module.
Each transliteration module is registered under a different
service name. The convention for the service name is
com.sun.star.i18n.Transliteration.l10n.{implName}. The
{implName} is a unique name used to identify a module. The
implName is used to get a localized name for the transliteration
module. The implName is used in locale data to list the
available transliteration modules for the locale. There are some
transliteration modules that are always available. The names of
those modules are listed as enum
TransliterationModules names. For modules not
listed there it is possible to load them directly by their
implName.
- Parameter aImplName
- The module's {implName} under which it is registered with
com.sun.star.i18n.Transliteration.l10n.{implName}.
|
|
loadModulesByImplNames
| void |
| loadModulesByImplNames( |
[in] sequence< string > |
aImplNameList, |
| [in] ::com::sun::star::lang::Locale |
aLocale ); |
- Description
- Load a sequence of instances of transliteration modules.
Output of one module is feeded as input to the next module in
the sequence. The object created by this call has
TransliterationType CASCADE and IGNORE types.
- Parameter aImplNameList
- Only IGNORE type modules can be specified.
|
|
getAvailableModules
| sequence< string > |
| getAvailableModules( |
[in] ::com::sun::star::lang::Locale |
aLocale, |
| [in] short |
nType ); |
- Description
- List the available transliteration modules for a given locale.
It can be filtered based on its type.
- Parameter nType
- A bitmask field of values defined in
TransliterationType
|
|
transliterate
| string |
| transliterate( |
[in] string |
aInStr, |
| [in] long |
nStartPos, |
| [in] long |
nCount, |
| [out] sequence< long > |
rOffset ); |
- Description
- Transliterate a substring. This method can be called if the
object doesn't have TransliterationType IGNORE
attribute.
- Parameter aStr
- The input string.
- Parameter nStartPos
- Start position within aStr from where transliteration starts.
- Parameter nCount
- Number of codepoints to be transliterated.
- Parameter rOffset
- To find the grapheme of input string corresponding to the
grapheme of output string, rOffset provides the offset array
whose index is the offset of output string, the element
containing the position within the input string before
transliteration.
|
|
folding
| string |
| folding( |
[in] string |
aInStr, |
| [in] long |
nStartPos, |
| [in] long |
nCount, |
| [out] sequence< long > |
rOffset ); |
- Usage Restrictions
- deprecated
- Deprecation Info
- For internal use, this method is supported to get the
"transliteration", which equals() is based on.
|
|
equals
| boolean |
| equals( |
[in] string |
aStr1, |
| [in] long |
nPos1, |
| [in] long |
nCount1, |
| [out] long |
rMatch1, |
| [in] string |
aStr2, |
| [in] long |
nPos2, |
| [in] long |
nCount2, |
| [out] long |
rMatch2 ); |
- Description
- Match two substrings and find if they are equivalent as per this
transliteration.
This method can be called if the object has
TransliterationType IGNORE attribute.
Returns the number of matched code points in any case, even if
strings are not equal, for example:
equals( "a", 0, 1, nMatch1, "aaa", 0, 3, nMatch2 )
returns false and nMatch:=1 and nMatch2:=1
equals( "aab", 0, 3, nMatch1, "aaa", 0, 3, nMatch2 )
returns false and nMatch:=2 and nMatch2:=2
- Parameter aStr1
- First string to match.
- Parameter nPos1
- Start position within aStr1.
- Parameter nCount1
- Number of code points to use of aStr1.
- Parameter rMatch1
- Returns number of matched code points in aStr1.
- Parameter aStr2
- Second string to match.
- Parameter nPos2
- Start position within aStr2.
- Parameter nCount2
- Number of code points to use of aStr2.
- Parameter rMatch2
- Returns number of matched code points in aStr2.
- Returns
- true if the substrings are equal per this
transliteration
false else.
|
|
transliterateRange
| sequence< string > |
| transliterateRange( |
[in] string |
aStr1, |
| [in] string |
aStr2 ); |
- Description
- Transliterate one set of characters to another.
This method is intended for getting corresponding ranges and
can be called if the object has TransliterationType
IGNORE attribute.
For example: generic CASE_IGNORE transliterateRange( "a", "i" )
returns {"A","I","a","i"}, transliterateRange( "a", "a" )
returns {"A","A","a","a"}.
Use this transliteration to create regular expresssions like
[a-i] --> [A-Ia-i].
- Returns
- String sequence containing corresponding transliterated
pairs of characters to represent a range.
|
|
compareSubstring
| long |
| compareSubstring( |
[in] string |
aStr1, |
| [in] long |
nOff1, |
| [in] long |
nLen1, |
| [in] string |
aStr2, |
| [in] long |
nOff2, |
| [in] long |
nLen2 ); |
- Description
- Compare 2 substrings as per this transliteration. It translates both
substrings before comparing them.
- Parameter aStr1
- First string.
- Parameter nOff1
- Offset (from 0) of the first substring.
- Parameter nLen1
- Length (from offset) of the first substring.
- Parameter aStr2
- Second string.
- Parameter nOff2
- Offset (from 0) of the second substring.
- Parameter nLen2
- Length (from offset) of the second substring.
- Returns
- 1 if the first substring is greater than the second substring
0 if the first substring is equal to the second substring
-1 if the first substring is less than the second substring
|
|
compareString
| long |
| compareString( |
[in] string |
aStr1, |
| [in] string |
aStr2 ); |
- Description
- Compare 2 strings as per this transliteration. It translates both
strings before comparing them.
- Returns
- 1 if the first string is greater than the second string
0 if the first string is equal to the second string
-1 if the first string is less than the second string
|
|
Copyright © 2013, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


{% extends "layout.html" %} {% block body %} Warning: Javascript seems to be disabled This website requires that Javascript be enabled on your browser. Instructions for enabling Javascript in your browser can be found here
This website requires that Javascript be enabled on your browser.
Instructions for enabling Javascript in your browser can be found here


About Kyle
Kyle is digging JavaScript right now.
Things Kyle Likes
Rain drops on roses
Whiskers on kittens
Beer
Things Kyle Does Not Like
Sweet potatoes
Crowds
Top Ten NHL Teams
Canucks
Panthers
Islanders
Blackhawks
Blues
Stars
Coyotes
Maple Leafs
Wild
Lightning


Last summer, my adventuring party took me and
on a trip to
. The weather there is very
! Northern
has many
, and they make
there. Many people also go to
to
or see the
. The people that live there love to eat
and are very proud of their big
. The also like to
in the sun and swim in the
! It was a really
trip!


Contents
This is a design document describing how tests which use multiple versions of Ganeti can be introduced into the current build infrastructure.
The testing of Ganeti is currently done by using two different approaches - unit tests and QA. While the former are useful for ensuring that the individual parts of the system work as expected, most errors are discovered only when all the components of Ganeti interact during QA.
However useful otherwise, until now the QA has failed to provide support for testing upgrades and version compatibility as it was limited to using only one version of Ganeti. While these can be tested for every release manually, a systematic approach is preferred and none can exist with this restriction in place. To lift it, the buildbot scripts and QA utilities must be extended to allow a way of specifying and using diverse multi-version checks.
There are two classes of multi-version tests that are interesting in Ganeti, and this chapter provides an example from each to highlight what should be accounted for in the design.
One interface Ganeti exposes to clients interested in interacting with it is the RAPI. Its stability has always been a design principle followed during implementation, but whether it held true in practice was not asserted through tests.
An automatic test of RAPI compatibility would have to take a diverse set of RAPI requests and perform them on two clusters of different versions, one of which would be the reference version. If the clusters had been identically configured, all of the commands successfully executed on the reference version should succeed on the newer version as well.
To achieve this, two versions of Ganeti can be run separately on a cleanly setup cluster. With no guarantee that the versions can coexist, the deployment of these has to be separate. A proxy placed between the client and Ganeti records all the requests and responses. Using this data, a testing utility can decide if the newer version is compatible or not, and provide additional information to assist with debugging.
An upgrade / downgrade test serves to examine whether the state of the cluster is unchanged after its configuration has been upgraded or downgraded to another version of Ganeti.
The test works with two consecutive versions of Ganeti, both installed on the same machine. It examines whether the configuration data and instances survive the downgrade and upgrade procedures. This is done by creating a cluster with the newer version, downgrading it to the older one, and upgrading it to the newer one again. After every step, the integrity of the cluster is checked by running various operations and ensuring everything still works.
Although the previous examples have not been selected to show use cases as diverse as possible, they still show a number of dissimilarities:
With the first two real use cases demonstrating such diversity, it does not make sense to design multi-version test classes. Instead, the programmability of buildbot’s configuration files can be leveraged to implement each test as a separate builder with a custom sequence of steps. The individual steps such as checking out a given or previous version, or installing and removing Ganeti, will be provided as utility functions for any test writer to use.
An upgrade / downgrade test is a part of the QA suite as of commit aa104b5e. The test and the corresponding buildbot changes are a very good first step, both by showing that multi-version tests can be done, and by providing utilities needed for builds of multiple branches. Previously, the same folder was used as the base directory of any build, and now a directory structure more accommodating to multiple builds is in place.
The builder running the test has one flaw - regardless of the branch submitted, it compares versions 2.10 and 2.11 (current master). This behaviour is different from any of the other builders, which may restrict the branches a test can be performed on, but do not differentiate between them otherwise. While additional builders for different versions pairs may be added, this is not a good long-term solution.
The test can be improved by making it compare the current and the previous version. As the buildbot has no notion of what a previous version is, additional utilities to handle this logic will have to be introduced.
The upgrade / downgrade test should be generalized to work for any version which can be downgraded from and upgraded to automatically, meaning versions from 2.11 onwards. This will be made challenging by the fact that the previous version has to be checked out by reading the version of the currently checked out code, identifying the previous version, and then making yet another checkout.
The major and minor version can be read from a Ganeti repository in multiple ways. The two are present as constants defined in source files, but due to refactorings shifting constants from the Python to the Haskell side, their position varies across versions. A more reliable way of fetching them is by examining the news file, as it obeys strict formatting restrictions.
With the version found, a script that acts as a previous version lookup table can be invoked. This script can be constructed dynamically upon buildbot startup, and specified as a build step. The checkout following it proceeds as expected.
The RAPI compatibility test should be added as a separate builder afterwards. As the test requires additional comparison and proxy logic to be used, it will be enabled only on 2.11 onwards, comparing the versions to 2.6 - the reference version for the RAPI. Details on the design of this test will be added in a separate document.
While there are many advantages to having a single builder representing a multi-version test, working on every branch, there is at least one disadvantage: the need to define a base or reference version, which is the only version that can be used to trigger the test, and the only one on which code changes can be tried.
If an error is detected while running a test, and the issue lies with a version other than the one used to invoke the test, the fix would have to make it into the repository before the test could be tried again.
For simple tests, the issue might be mitigated by running them locally. However, the multi-version tests are more likely to be complicated than not, and it could be difficult to reproduce a test by hand.
The situation can be made simpler by requiring that any multi-version test can use only versions lower than the reference version. As errors are more likely to be found in new rather than old code, this would at least reduce the number of troublesome cases.


SweetFreeStuff.com
///////////////////////////////////////////
Free 4-Pack of Dream Water (Video Submission) and $10k Sweepstakes
Posted: 25 Aug 2013 11:28 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/KjOp7e9kM1U/?utm_source=feedburner&utm_medium=email
Submit a video detailing your dream and receive a free 4-Pack of Dream
Water as well as enter their sweepstakes. Free 4-Pack of Dream Water
///////////////////////////////////////////
Free Sample of Estee Lauders Advanced Night Repair Serum
Posted: 25 Aug 2013 05:48 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/bP5pQ8TeY0U/?utm_source=feedburner&utm_medium=email
Share your Message and you will receive an offer by e-mail to receive a
in-store sample. Free Sample of Estee Lauders Advanced Night Repair Serum
///////////////////////////////////////////
Free Sample of Minties Dog Treats (Sams Club)
Posted: 25 Aug 2013 04:00 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/A4RP-ws7-YE/?utm_source=feedburner&utm_medium=email
Watch the video, then sample link will appear. It is for one medium sized
bone. Currently does not requires a Sams Club membership number. Free
Minties Dog Treats Sample
///////////////////////////////////////////
Free Sample of Muscle Tech Bodybuilding Supplement
Posted: 25 Aug 2013 03:37 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/gmrUVTHAZss/?utm_source=feedburner&utm_medium=email
Click the Samples link at the bottom of the page.
///////////////////////////////////////////
Free Beech-Nut Next Steps Kit
Posted: 25 Aug 2013 01:05 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/qfMKqEDPWM8/?utm_source=feedburner&utm_medium=email
Please fill out this form to receive your free Next Steps Kit in the mail
and the monthly eNewsletter filled with helpful advice and money-saving
coupons. If you are already receiving our eNewsletter, delivery will
continue without interruption.
///////////////////////////////////////////
SwagBucks Rewards
Posted: 25 Aug 2013 01:00 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/rZifzEhH8g4/?utm_source=feedburner&utm_medium=email
Swagbucks is a loyalty program where you can earn free stuff including
1,000s of products for doing the things you do everyday! Sign up and get 30
free Swagbucks!
///////////////////////////////////////////
Free Sample of Nectresse Natural No Calorie Sweetener
Posted: 25 Aug 2013 12:15 AM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/-2BifIcuJd0/?utm_source=feedburner&utm_medium=email
Free Sample of Nectresse Natural No Calorie Sweetener
///////////////////////////////////////////
Free Sample of Cafe Bustelo Coffee
Posted: 24 Aug 2013 10:02 PM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/-QL_eG1nKHw/?utm_source=feedburner&utm_medium=email
Like their Facebook page to sign up for a sample for you and a friend.
Cannot be accessed using mobile devices.
///////////////////////////////////////////
Dont Forget to Enter the SweetFreeStuff.com $75 Amazon Gift Card Giveaway!!!
Posted: 24 Aug 2013 10:01 PM PDT
http://feedproxy.google.com/&;r/SweetFreeStuff/&;3/qQqNDCmeXxQ/?utm_source=feedburner&utm_medium=email
Click Here to Enter the Giveaway Now!


|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PanelAction
| Nested Class Summary | |
|---|---|
static class |
PanelAction.ActionStage
pre panel activation stage |
| Field Summary | |
|---|---|
static java.lang.String |
PANEL_ACTION_CLASSNAME_TAG
attribute for class to use |
static java.lang.String |
PANEL_ACTION_CONFIGURATION_TAG
tag-name for the configuration of an action. |
static java.lang.String |
PANEL_ACTION_STAGE_TAG
attribute for the stage of the action |
static java.lang.String |
PANEL_ACTION_TAG
tag-name of the panel action |
static java.lang.String |
PANEL_ACTIONS_TAG
tag-name of the panel action |
| Method Summary | |
|---|---|
void |
executeAction(AutomatedInstallData adata,
AbstractUIHandler handler)
|
void |
initialize(PanelActionConfiguration configuration)
Initializes the PanelAction with the given configuration. |
| Field Detail |
|---|
static final java.lang.String PANEL_ACTIONS_TAG
static final java.lang.String PANEL_ACTION_TAG
static final java.lang.String PANEL_ACTION_STAGE_TAG
static final java.lang.String PANEL_ACTION_CONFIGURATION_TAG
static final java.lang.String PANEL_ACTION_CLASSNAME_TAG
| Method Detail |
|---|
void executeAction(AutomatedInstallData adata, AbstractUIHandler handler)
adata
- - AutomatedInstallData instancehandler
- - actual UIHandler (
NOTE:
On a preconstruct action the handler is null because it is not available until it is constructed.
During an automated installation the handler is null on each action because we have no GUI to handle.void initialize(PanelActionConfiguration configuration)
configuration
- an PanelActionConfiguration containing the configuration of the action or
null if no configuration was found.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


PNGJ: A simple library for reading/writing PNG images.
See the docs and source of the samples for more.
http://code.google.com/p/pngj/ PNGJ
Hernán J. González hgonzalez@gmail.com