Skip to content

Commit

Permalink
Move Server-Methods into Factory (#1101)
Browse files Browse the repository at this point in the history
* Move Server-Methods into Factory

* Rename to Server.md

* Update Readme.md
  • Loading branch information
allevo authored and mcollina committed Aug 26, 2018
1 parent ba9a629 commit e6bca66
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 207 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -136,7 +136,7 @@ matters to you.

## Documentation
* <a href="https://github.com/fastify/fastify/blob/master/docs/Getting-Started.md"><code><b>Getting Started</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md"><code><b>Server Methods</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Server.md"><code><b>Server</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Routes.md"><code><b>Routes</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Logging.md"><code><b>Logging</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Middlewares.md"><code><b>Middlewares</b></code></a>
Expand All @@ -147,7 +147,6 @@ matters to you.
* <a href="https://github.com/fastify/fastify/blob/master/docs/Reply.md"><code><b>Reply</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Request.md"><code><b>Request</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/ContentTypeParser.md"><code><b>Content Type Parser</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Factory.md"><code><b>Factory</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Plugins.md"><code><b>Plugins</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Testing.md"><code><b>Testing</b></code></a>
* <a href="https://github.com/fastify/fastify/blob/master/docs/Benchmarking.md"><code><b>Benchmarking</b></code></a>
Expand Down
4 changes: 2 additions & 2 deletions docs/ContentTypeParser.md
Expand Up @@ -38,7 +38,7 @@ if (!fastify.hasContentTypeParser('application/jsoff')){
```

#### Body Parser
You can parse the body of the request in two ways. The first one is shown above: you add a custom content type parser and handle the request stream. In the second one you should pass a `parseAs` option to the `addContentTypeParser` API, where you declare how you want to get the body, it could be `'string'` or `'buffer'`. If you use the `parseAs` option Fastify will internally handle the stream and perform some checks, such as the [maximum size](https://github.com/fastify/fastify/blob/master/docs/Factory.md#factory-body-limit) of the body and the content length. If the limit is exceeded the custom parser will not be invoked.
You can parse the body of the request in two ways. The first one is shown above: you add a custom content type parser and handle the request stream. In the second one you should pass a `parseAs` option to the `addContentTypeParser` API, where you declare how you want to get the body, it could be `'string'` or `'buffer'`. If you use the `parseAs` option Fastify will internally handle the stream and perform some checks, such as the [maximum size](https://github.com/fastify/fastify/blob/master/docs/Server.md#factory-body-limit) of the body and the content length. If the limit is exceeded the custom parser will not be invoked.
```js
fastify.addContentTypeParser('application/json', { parseAs: 'string' }, function (req, body, done) {
try {
Expand All @@ -56,7 +56,7 @@ See [`example/parser.js`](https://github.com/fastify/fastify/blob/master/example

##### Custom Parser Options
+ `parseAs` (string): Either `'string'` or `'buffer'` to designate how the incoming data should be collected. Default: `'buffer'`.
+ `bodyLimit` (number): The maximum payload size, in bytes, that the custom parser will accept. Defaults to the global body limit passed to the [`Fastify factory function`](https://github.com/fastify/fastify/blob/master/docs/Factory.md#bodylimit).
+ `bodyLimit` (number): The maximum payload size, in bytes, that the custom parser will accept. Defaults to the global body limit passed to the [`Fastify factory function`](https://github.com/fastify/fastify/blob/master/docs/Server.md#bodylimit).

#### Catch All
There are some cases where you need to catch all requests regardless of their content type. With Fastify, you just need to add the `'*'` content type.
Expand Down
196 changes: 0 additions & 196 deletions docs/Factory.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Logging.md
Expand Up @@ -46,7 +46,7 @@ fastify.get('/', options, function (request, reply) {

<a name="logging-request-id" />

By default fastify adds an id to every request for easier tracking. If the "request-id" header is present its value is used, otherwise a new incremental id is generated. See Fastify Factory [`requestIdHeader`](https://github.com/fastify/fastify/blob/master/docs/Factory.md#factory-request-id-header) options for customizing that header name.
By default fastify adds an id to every request for easier tracking. If the "request-id" header is present its value is used, otherwise a new incremental id is generated. See Fastify Factory [`requestIdHeader`](https://github.com/fastify/fastify/blob/master/docs/Server.md#factory-request-id-header) options for customizing that header name.
Additionally, `genReqId` option can be used for generating the request id by yourself. It will received the incoming request as a parameter.

```js
Expand Down
4 changes: 2 additions & 2 deletions docs/Reply.md
Expand Up @@ -170,10 +170,10 @@ fastify.get('/', function (request, reply) {
})
```

If you want to completely customize the error response, checkout [`setErrorHandler`](https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md#seterrorhandler) API.
If you want to completely customize the error response, checkout [`setErrorHandler`](https://github.com/fastify/fastify/blob/master/docs/Server.md#seterrorhandler) API.

Errors with a `status` or `statusCode` property equal to `404` will be routed to the not found handler.
See [`server.setNotFoundHandler`](https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md#setnotfoundhandler)
See [`server.setNotFoundHandler`](https://github.com/fastify/fastify/blob/master/docs/Server.md#setnotfoundhandler)
API to learn more about handling such cases:

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/Routes.md
Expand Up @@ -234,7 +234,7 @@ Be aware that if you use [`fastify-plugin`](https://github.com/fastify/fastify-p
It could happen that you need different log levels in your routes, with Fastify achieve this is very straightforward.<br/>
You just need to pass the option `logLevel` to the plugin option or the route option with the [value](https://github.com/pinojs/pino/blob/master/docs/API.md#discussion-3) that you need.

Be aware that if you set the `logLevel` at plugin level, also the [`setNotFoundHandler`](https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md#setnotfoundhandler) and [`setErrorHandler`](https://github.com/fastify/fastify/blob/master/docs/Server-Methods.md#seterrorhandler) will be affected.
Be aware that if you set the `logLevel` at plugin level, also the [`setNotFoundHandler`](https://github.com/fastify/fastify/blob/master/docs/Server.md#setnotfoundhandler) and [`setErrorHandler`](https://github.com/fastify/fastify/blob/master/docs/Server.md#seterrorhandler) will be affected.

```js
// server.js
Expand Down

0 comments on commit e6bca66

Please sign in to comment.