Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): plugin to serve static files #1753

Merged
merged 3 commits into from Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 53 additions & 29 deletions docs/_api/formatters.md
Expand Up @@ -7,14 +7,14 @@ permalink: /docs/formatters-api/

### Table of Contents

- [Usage](#usage)
- [Types](#types)
- [formatter](#formatter)
- [Included formatters](#included-formatters)
- [formatText](#formattext)
- [formatJSON](#formatjson)
- [formatJSONP](#formatjsonp)
- [formatBinary](#formatbinary)
- [Usage][1]
- [Types][2]
- [formatter][3]
- [Included formatters][4]
- [formatText][5]
- [formatJSON][6]
- [formatJSONP][7]
- [formatBinary][8]

## Usage

Expand Down Expand Up @@ -48,15 +48,15 @@ var server = restify.createServer({

Format a response for being sent over the wire

Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
Type: [Function][9]

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body to format
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body to format

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** formatted response data
Returns **[String][11]** formatted response data

## Included formatters

Expand All @@ -71,12 +71,12 @@ exists. If it doesn't, then the response is a zero-length string.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body. If it has a toString() method this
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body. If it has a toString() method this
will be used to make the string representation

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatJSON

Expand All @@ -85,11 +85,11 @@ exist then a JSON.stringify will be attempted.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object (not used)
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object (not used)
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatJSONP

Expand All @@ -98,20 +98,44 @@ Unicode escapes line and paragraph separators.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data
Returns **[String][11]** data

### formatBinary

Binary formatter.

**Parameters**

- `req` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the request object
- `res` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the response object
- `body` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response body
- `req` **[Object][10]** the request object
- `res` **[Object][10]** the response object
- `body` **[Object][10]** response body

Returns **[Buffer](https://nodejs.org/api/buffer.html)** body
Returns **[Buffer][12]** body

[1]: #usage

[2]: #types

[3]: #formatter

[4]: #included-formatters

[5]: #formattext

[6]: #formatjson

[7]: #formatjsonp

[8]: #formatbinary

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[12]: https://nodejs.org/api/buffer.html