Commit Graph

88 Commits

Author SHA1 Message Date
sigma-andex
6f0ca26a1b Minor improvement in the handler 2022-08-25 12:02:28 +01:00
sigma-andex
ef72a4476c Cleanup and export everything necessary 2022-08-25 12:02:28 +01:00
sigma-andex
7706ae80a6 Minor cleanup 2022-08-25 12:02:28 +01:00
sigma-andex
f08f606149 Make nodeMiddleware optional 2022-08-25 12:02:28 +01:00
sigma-andex
7fb9ed53b9 Simplify extended request creation 2022-08-25 12:02:28 +01:00
sigma-andex
41a7843507 Add NodeMiddlewareStack 2022-08-25 12:02:28 +01:00
sigma-andex
5e3f5a77a8 Some cleanup 2022-08-25 12:02:28 +01:00
sigma-andex
79e88a71e1 First working version supporting node middlewares 2022-08-25 12:02:28 +01:00
sigma-andex
ac6f9318a0 Remove unused import 2022-06-16 20:06:07 +01:00
sigma-andex
88169cd299 Separate headers into request and response headers
- Add response header construction using records
- Update tests and examples
- Update doc
2022-06-16 20:06:07 +01:00
sigma-andex
8733799cb0 WIP 2022-06-16 20:06:07 +01:00
sigma-andex
f8e53eca35 WIP: Separate request and response headers
- Add simplified headers creation mechanism
2022-06-16 20:06:07 +01:00
sigma-andex
2c98091800
Format code 2022-06-13 15:44:32 +01:00
sigma-andex
8375ce788b Add catchAll route and update documentation 2022-06-13 15:12:05 +01:00
sigma-andex
6072f4ce9e Format code 2022-06-06 21:18:04 +01:00
sigma-andex
12726379bf Add validator continuation
Update routing readme
2022-06-06 21:18:04 +01:00
sigma-andex
2ef550ef33 Add encoder exports 2022-06-05 20:53:52 +01:00
sigma-andex
e2f89f42e8 Format code 2022-06-05 20:53:52 +01:00
sigma-andex
183561d251 Add encoder 2022-06-05 20:53:52 +01:00
sigma-andex
4c6d57ed1d Format code 2022-06-05 20:53:52 +01:00
sigma-andex
01cf6ca842 Relax aff to m 2022-06-05 20:53:52 +01:00
sigma-andex
f928e1b988 Add documentation 2022-06-05 20:53:52 +01:00
sigma-andex
a7e1f4e309 Add json request parsing
- Use json drivers to support different json libraries like argonaut or
  yoga-json
- Use continuations to simplify parsing and short-circuit bad requests
2022-06-05 20:53:52 +01:00
sigma-andex
1008b89a84 Format code 2022-05-26 11:54:14 +01:00
sigma-andex
95797c8938 Improve stopping message 2022-05-26 11:54:14 +01:00
sigma-andex
0ace3c0797 Add Generic to reexports, improve closing messages 2022-05-26 11:54:14 +01:00
sigma-andex
cf0c786fc0 Format code 2022-05-25 19:27:02 +01:00
sigma-andex
f3837b0563 Reexport routing-duplex to simplify imports 2022-05-25 19:27:02 +01:00
sigma-andex
345675d5bd Make settings optional
- Add default onStarted and closingHandler
- Use justifill to easily add options
- Remove multiple serve options
2022-05-22 17:37:42 +01:00
sigma-andex
c16eb2bdcc Rename modules and rudimentarily update readme 2022-05-22 12:48:32 +01:00
sigma-andex
9a8f34cf73 Update HTTPure to routing duplex 2022-05-22 12:34:27 +01:00
sigma-andex
24197a474a First working example of routing duplex 2022-05-22 12:34:27 +01:00
Thomas Honeyman
42bf4475e0
Update for PureScript 0.15 (#194)
* Update shell and packages

* Fix code for 0.15

* Fix tests

* Format

* Add check-pulp command

* Generate bowerfile

* Add check-pulp to CI

* Add nixfmt to formatting

* Fixup test helpers

* Take 2

* PR comments (#1)

* Nix cleanup from PR

* Use arrows functions

* Remove unnecessary step

Co-authored-by: Connor Prussin <connor@prussin.net>
2022-05-04 14:02:29 -07:00
Wenbo Gao
4319cffed6
Cache Body toBuffer/toString Results (#189)
* cache `body` processing results (Buffer, String) with `Ref`

* add `readBodyAs(Buffer|Stream|String)` for accessing `body`

* fix tests

* add tests for `readBodyAsBuffer` and `readBodyAsString`

* move Body to HTTPure.Body and rename it to RequestBody

* add HTTPure.Body.toStream

* consolidate `readBodyAs(Buffer|String)` into `to(Buffer|String)`

and move `Ref` from top level `body` down to `buffer` and `string` fields

* fix tests

* import constructors explicitly

* revert changes

This reverts commit e53188c3e6d74ca00d3d891829ca91f0803b870b.

* update `Body.read` to return `RequestBody`
2021-12-06 20:59:53 -08:00
Arthur Xavier
c34b341a03
Support 'Duplex' streams in the existing 'Body' instance for streams (#187) 2021-11-29 09:09:40 -08:00
Connor Prussin
8295d8755e
Clean up imports (#185)
* Clean up import declarations to only use qualified when necessary

* Remove unused imports
2021-11-18 22:16:35 -08:00
Connor Prussin
6e886b91ac
Add support for non string requests (#184)
* First version of supporting non-string requests

* Clean up

* Minor cleanup

* Simplify to directly export the stream

* Add nl

* Clean up & add more testing

Co-authored-by: sigma-andex <sigma.andex@pm.me>
2021-11-15 20:02:36 -08:00
Thomas Honeyman
6ce52417f7
Migrate from purty to purs-tidy (#178)
* Replace purty with purs-tidy

* run purs-tidy
2021-11-06 12:37:31 -07:00
Connor Prussin
c075df65d7
Ensure correct ordering on stream operations (#176) 2021-06-25 10:58:16 -07:00
Connor Prussin
1ad5a08306
Add code formatting with purty (#171)
* Add code formatting with purty

* Purtify code
2021-03-22 12:02:36 -07:00
Victor Peter Rouven Müller
ab8c1fe88c
Update to purescript 0.14 (#167) 2021-03-03 11:16:22 -08:00
Tim McIver
b3eb977096
Fix HTTPure.Utils.replacePlus (#166)
* Create failing test.

* Fix code so failing test passes.
2020-11-14 13:09:07 -08:00
paluh
896956b762
Expose original request url as a part of Request (#155) 2020-03-09 08:34:04 -07:00
Connor Prussin
61b88de59b
#153 bind to 0.0.0.0 instead of localhost (#154)
* Bind to 0.0.0.0 instead of localhost

* Don't use nixjs for purescript

* Use lorri

* Use niv

* Use nix for travis build

* Clean up travis config
2020-02-26 16:43:38 -08:00
Drew Olson
ac43b0d125 Update response functions to return MonadAff m => m Response (#150)
* Update Response functions to return MonadAffs

* Install psc-package for travis build
2019-09-29 20:57:15 -07:00
Gareth Smith
d37096dcce Add some type declarations to get compatibility with node-buffer 6.x. (#149)
Since node-buffer 6.x is not yet in the package set, compatibility with
node-buffer 5.x is maintained.
2019-09-24 17:09:29 -07:00
Nick Saunders
88e1dcde9e Provide utils from purescript-globals instead of FFI (#145) 2019-08-16 12:03:38 -07:00
Ping Chen
2a02d41954 Use Buffer.concat instead of string concatenation (#141)
* Bump dependency versions

* Use Buffer.concat, then convert to string on end
2019-06-03 10:43:10 -07:00
Hardy Jones
5d7c2c8bda Use CaseInsensitiveString for Headers (#138)
* v0.8.1

* Add failing tests for `Headers`

There's currently a bug with `Headers`:
if a header is created with uppercase characters, it can never be found.
The problem is that we only look for lowercase characters in the
`Lookup` instance for `Headers`.

* Convert `Headers` to use `CaseInsensitiveString`

In an effort to be more true to HTTP,
we make the header keys case-insensitive.
This fixes the issue of looking up a header where the casing is different,
Since `CaseInsensitiveString`s compare in a way that ignore casing.

The API for consumers for `Headers` stays the same,
but we get more correct code.
A win for all!
2019-04-25 20:06:15 -07:00
Hardy Jones
c208dffb7b Add HTTP version (#137)
* v0.8.1

* Add the HTTP version to `Request`

The `node-http` `Request` has the HTTP version on it.
We can make it available in our `Request` for consumers.

We went the naive approach first and typed it as a string.
There is some structure to the version,
so we could attempt to parse it.
It's unclear what we would do if parsing failed though.

Maybe we want something like:
```PureScript
data Version
  = Known { major :: Int, minor :: Int }
  | Unknown String
```

That would allow us to parse the known format,
and fallback to accepting anything else.
It's definitely something to discuss anyway.

* Make HTTP version its own data type

There are only a handful of HTTP versions that are commonly used.
We can talk about those explicitly and fallback to any arbitrary version.

The changes here try to follow the patterns elsewhere in the code base.
Hopefully, it's not too far off.
2019-04-25 10:13:04 -07:00