summaryrefslogtreecommitdiff
path: root/http/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'http/README.md')
-rw-r--r--http/README.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/http/README.md b/http/README.md
index 448692a68..c7bac3f09 100644
--- a/http/README.md
+++ b/http/README.md
@@ -2,6 +2,45 @@
A framework for creating HTTP/HTTPS server.
+## Cookie
+
+Helper to manipulate `Cookie` throught `ServerRequest` and `Response`.
+
+```ts
+import { getCookies } from "https://deno.land/std/http/cookie.ts";
+
+let req = new ServerRequest();
+req.headers = new Headers();
+req.headers.set("Cookie", "full=of; tasty=chocolate");
+
+const c = getCookies(request);
+// c = { full: "of", tasty: "chocolate" }
+```
+
+To set a `Cookie` you can add `CookieOptions` to properly set your `Cookie`
+
+```ts
+import { setCookie } from "https://deno.land/std/http/cookie.ts";
+
+let res: Response = {};
+res.headers = new Headers();
+setCookie(res, { name: "Space", value: "Cat" });
+```
+
+Deleting a `Cookie` will set its expiration date before now.
+Forcing the browser to delete it.
+
+```ts
+import { delCookie } from "https://deno.land/std/http/cookie.ts";
+
+let res = new Response();
+delCookie(res, "deno");
+// Will append this header in the response
+// "Set-Cookie: deno=; Expires=Thus, 01 Jan 1970 00:00:00 GMT"
+```
+
+**Note**: At the moment multiple `Set-Cookie` in a `Response` is not handled.
+
## Example
```typescript