Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / serve-favicon / README.md
1 # serve-favicon
2
3 [![NPM Version][npm-image]][npm-url]
4 [![NPM Downloads][downloads-image]][downloads-url]
5 [![Linux Build][travis-image]][travis-url]
6 [![Windows Build][appveyor-image]][appveyor-url]
7 [![Test Coverage][coveralls-image]][coveralls-url]
8 [![Gittip][gittip-image]][gittip-url]
9
10 Node.js middleware for serving a favicon.
11
12 A favicon is a visual cue that client software, like browsers, use to identify
13 a site. For an example and more information, please visit
14 [the Wikipedia article on favicons](https://en.wikipedia.org/wiki/Favicon).
15
16 Why use this module?
17
18   - User agents request `favicon.ico` frequently and indiscriminately, so you
19     may wish to exclude these requests from your logs by using this middleware
20     before your logger middleware.
21   - This module caches the icon in memory to improve performance by skipping
22     disk access.
23   - This module provides an `ETag` based on the contents of the icon, rather
24     than file system properties.
25   - This module will serve with the most compatible `Content-Type`.
26
27 **Note** This module is exclusively for serving the "default, implicit favicon",
28 which is `GET /favicon.ico`. For additional vendor-specific icons that require
29 HTML markup, additional middleware is required to serve the relevant files, for
30 example [serve-static](https://npmjs.org/package/serve-static).
31
32 ## Install
33
34 This is a [Node.js](https://nodejs.org/en/) module available through the
35 [npm registry](https://www.npmjs.com/). Installation is done using the
36 [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
37
38 ```bash
39 npm install serve-favicon
40 ```
41
42 ## API
43
44 ### favicon(path, options)
45
46 Create new middleware to serve a favicon from the given `path` to a favicon file.
47 `path` may also be a `Buffer` of the icon to serve.
48
49 #### Options
50
51 Serve favicon accepts these properties in the options object.
52
53 ##### maxAge
54
55 The `cache-control` `max-age` directive in `ms`, defaulting to 1 year. This can
56 also be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)
57 module.
58
59 ## Examples
60
61 Typically this middleware will come very early in your stack (maybe even first)
62 to avoid processing any other middleware if we already know the request is for
63 `/favicon.ico`.
64
65 ### express
66
67 ```javascript
68 var express = require('express');
69 var favicon = require('serve-favicon');
70
71 var app = express();
72 app.use(favicon(__dirname + '/public/favicon.ico'));
73
74 // Add your routes here, etc.
75
76 app.listen(3000);
77 ```
78
79 ### connect
80
81 ```javascript
82 var connect = require('connect');
83 var favicon = require('serve-favicon');
84
85 var app = connect();
86 app.use(favicon(__dirname + '/public/favicon.ico'));
87
88 // Add your middleware here, etc.
89
90 app.listen(3000);
91 ```
92
93 ### vanilla http server
94
95 This middleware can be used anywhere, even outside express/connect. It takes
96 `req`, `res`, and `callback`.
97
98 ```javascript
99 var http = require('http');
100 var favicon = require('serve-favicon');
101 var finalhandler = require('finalhandler');
102
103 var _favicon = favicon(__dirname + '/public/favicon.ico');
104
105 var server = http.createServer(function onRequest(req, res) {
106   var done = finalhandler(req, res);
107
108   _favicon(req, res, function onNext(err) {
109     if (err) return done(err);
110
111     // continue to process the request here, etc.
112
113     res.statusCode = 404;
114     res.end('oops');
115   });
116 });
117
118 server.listen(3000);
119 ```
120
121 ## License
122
123 [MIT](LICENSE)
124
125 [npm-image]: https://img.shields.io/npm/v/serve-favicon.svg
126 [npm-url]: https://npmjs.org/package/serve-favicon
127 [travis-image]: https://img.shields.io/travis/expressjs/serve-favicon/master.svg?label=linux
128 [travis-url]: https://travis-ci.org/expressjs/serve-favicon
129 [appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-favicon/master.svg?label=windows
130 [appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-favicon
131 [coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-favicon.svg
132 [coveralls-url]: https://coveralls.io/r/expressjs/serve-favicon?branch=master
133 [downloads-image]: https://img.shields.io/npm/dm/serve-favicon.svg
134 [downloads-url]: https://npmjs.org/package/serve-favicon
135 [gittip-image]: https://img.shields.io/gittip/dougwilson.svg
136 [gittip-url]: https://www.gittip.com/dougwilson/