Skip to content

Commit 0e15846

Browse files
authored
Merge pull request #16 from dotkernel/arhimede
extended content validation
2 parents 17886ad + 5ec14d2 commit 0e15846

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

docs/book/v4/core-features/content-negotiation.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/book/v4/core-features/content-validation.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Content Negotiation
22

3-
Content negotiation validation in DotKernel happened through middleware, and it ensures that the incoming request
4-
and the outgoing response conform to the content types specified in the config file for all routes or for a specific
5-
route.
3+
**Content Negotiation** is performed by an application in order :
4+
5+
- To match the requested representation as specified by the client via the Accept header with a representation the
6+
application can deliver.
7+
- To determine the `Content-Type` of incoming data and deserialize it so the application can utilize it.
8+
9+
Essentially, content negotiation is the *client* telling the server what it is sending and what it wants in return, and
10+
the server determining if it can do what the client requests.
11+
12+
Content negotiation validation in **DotKernel API** happened through middleware, and it ensures that the incoming
13+
request and the outgoing response conform to the content types specified in the config file for all routes or for a
14+
specific route.
615

716
It performs validation on the `Accept` and `Content-Type` headers of the request and response and returning appropriate
817
errors responses when necessary.
@@ -51,7 +60,7 @@ GET /admin HTTP/1.1
5160
Accept: application/json
5261
```
5362

54-
This request indicates the client wants `applicaiton/json` in return. Now the server, through the config file will try
63+
This request indicates the client wants `application/json` in return. Now the server, through the config file will try
5564
to validate if that representation can be returned, basically if `application/json` is presented in the `Accept` key.
5665

5766
If the representation cannot be returned, a status code `406 - Not Acceptable` will be returned.
@@ -94,7 +103,7 @@ to be `multipart/form-data`. The above request will fail as the client send `app
94103
In addition to the validation described above, a third one is happening and is the last one, the server will check if
95104
the request `Accept` header can really be returned by the response.
96105

97-
Through how the DotKernel is returning a response in handler , a content type is always set, but this cannot be the case
98-
in any custom response but in any way the server will check what `Content-Type` the response is returning and will try
99-
to validate that against the `Accept` header of the request. If the validation fails, a status code
106+
Through how the **DotKernel API** is returning a response in handler , a content type is always set, but this cannot be
107+
the case in any custom response but in any way the server will check what `Content-Type` the response is returning and
108+
will try to validate that against the `Accept` header of the request. If the validation fails, a status code
100109
`406 - Not Acceptable` will be returned.

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ nav:
2525
- "Default Library Flow": v4/flow/default-library-flow.md
2626
- "Library Flow for Email": v4/flow/library-flow-for-email.md
2727
- Core Features:
28-
- "Content Negotiation": v4/core-features/content-negotiation.md
2928
- "Content Validation": v4/core-features/content-validation.md
3029
- "Exceptions": v4/core-features/exceptions.md
3130
- Tutorials:

0 commit comments

Comments
 (0)