Skip to content

Commit

Permalink
docs(readme): correct links to the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Feb 9, 2021
1 parent 7db5808 commit a1d3234
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -85,7 +85,7 @@ prob.toString() //=> [403] You do not have enough credit ('https://example.com/p

### Method : `<void>` `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'
Expand All @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a1d3234

Please sign in to comment.