Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fpapado/elm-set-cookie-parser
A parser for the Set-Cookie header, written in Elm.
https://github.com/fpapado/elm-set-cookie-parser
elm parser set-cookie
Last synced: 18 days ago
JSON representation
A parser for the Set-Cookie header, written in Elm.
- Host: GitHub
- URL: https://github.com/fpapado/elm-set-cookie-parser
- Owner: fpapado
- Created: 2018-10-27T14:06:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-28T18:29:34.000Z (about 6 years ago)
- Last Synced: 2024-11-11T10:53:14.531Z (3 months ago)
- Topics: elm, parser, set-cookie
- Language: Elm
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# elm-set-cookie-parser
> A parser for the Set-Cookie header, written in Elm.
:construction: Not yet published :construction:
## Usage
```elm
import SetCookieParser exposing (SetCookie)headerString = "count=300; Max-Age=12345; HttpOnly"
header : Result err SetCookie
header = SetCookieParser.fromString headerString
```## Why? Why not?
Mostly not.
There is probably no reason to want to parse this header on the client-side of a web app, since the browser does that already.
Similarly, on the server, there is more behaviour tied to Cookies, so your server most likely handles parsing already.
You also probably don't want to store/handle the cookies in scripts in the first place.Personally, I felt like trying out the Elm Parser API, because it looked fun! And the Set-Cookie header was giving me pain on another project recently, so it was a good chance to demystify it.
If you ever want to parse or understand the Set-Cookie header, I hope this can be a lightweight, readable version :)
## Development
Install the Elm dependencies:
```sh
npm install
```Run the test suite:
```sh
elm-test
```## Limitations
Here are some things I did not attempt currently.
Feel free to open an Issue to discuss before trying them out and sending a PR!- Only parses single headers at the moment. You would have to manually split a string that contains multiple headers.
- Does not attempt to parse the date in the "Expires" header at the moment.
## References
- [The Set-Cookie header is part of RFC 6265](https://tools.ietf.org/html/rfc6265)