diff --git a/README.md b/README.md index dab5cac..dee5ed4 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ npm install api-problem ### Constructor: `Problem(status[, title][, type][, members])` -| name | type | required | default | description | referece | -|---------------|----------|----------|--------------------|----------------------------------------------------------------------------------------|-----------------------------| -| **`status`** | `String` | `✔` | `N/A` | The HTTP status code generated by the origin server for this occurrence of the problem | \[Section 3.1\]\[spec-3.1\] | -| **`title`** | `String` | `✖` | HTTP status phrase | A short, human-readable summary of the problem type | \[Section 3.1\]\[spec-3.1\] | -| **`type`** | `String` | `✖` | `about:blank` | A URI reference that identifies the problem type | \[Section 3.1\]\[spec-3.1\] | -| **`details`** | `Object` | `✖` | `N/A` | additional details to attach to object | \[Section 3.1\]\[spec-3.2\] | +| name | type | required | default | description | referece | +|---------------|----------|----------|--------------------|----------------------------------------------------------------------------------------|----------------------------------------------------------------| +| **`status`** | `String` | `✔` | `N/A` | The HTTP status code generated by the origin server for this occurrence of the problem | [Section 3.1](https://tools.ietf.org/html/rfc7807#section-3.1) | +| **`title`** | `String` | `✖` | HTTP status phrase | A short, human-readable summary of the problem type | [Section 3.1](https://tools.ietf.org/html/rfc7807#section-3.1) | +| **`type`** | `String` | `✖` | `about:blank` | A URI reference that identifies the problem type | [Section 3.1](https://tools.ietf.org/html/rfc7807#section-3.1) | +| **`details`** | `Object` | `✖` | `N/A` | additional details to attach to object | [Section 3.1](https://tools.ietf.org/html/rfc7807#section-3.2) | ``` js import Problem from 'api-problem' @@ -85,7 +85,7 @@ prob.toString() //=> [403] You do not have enough credit ('https://example.com/p ### Method : `` `send(response)` -uses [`response.writeHead`](https://nodejs.org/docs/latest/api/http.html#http_response_writehead_statuscode_statusmessage_headers) and [`response.end`](https://nodejs.org/docs/latest/api/http.html#http_response_end_data_encoding_callback) to send an appropriate error respnse message with the `Content-Type` response header to \[`application/problem+json`\]\[spec-3\] +uses [`response.writeHead`](https://nodejs.org/docs/latest/api/http.html#http_response_writehead_statuscode_statusmessage_headers) and [`response.end`](https://nodejs.org/docs/latest/api/http.html#http_response_end_data_encoding_callback) to send an appropriate error respnse message with the `Content-Type` response header to [`application/problem+json`](https://tools.ietf.org/html/rfc7807#section-3) ``` js import http from 'http' @@ -97,7 +97,7 @@ Problem.send(response) ### Express Middleware -A standard connect middleware is provided. The middleware intercepts Problem objects thrown as exceptions and serializes them appropriately in the HTTP response while setting the `Content-Type` response header to \[`application/problem+json`\]\[spec-3\] +A standard connect middleware is provided. The middleware intercepts Problem objects thrown as exceptions and serializes them appropriately in the HTTP response while setting the `Content-Type` response header to [`application/problem+json`](https://tools.ietf.org/html/rfc7807#section-3) ``` js import express from 'express' diff --git a/docs/README.md b/docs/README.md index 01dbac9..16198f2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -102,3 +102,7 @@ app.get('/', (req, res) => { app.use(Middleware) ``` + +[spec-3]: https://tools.ietf.org/html/rfc7807#section-3 +[spec-3.1]: https://tools.ietf.org/html/rfc7807#section-3.1 +[spec-3.2]: https://tools.ietf.org/html/rfc7807#section-3.2