Rename modules and rudimentarily update readme
This commit is contained in:
parent
dc245bbfc7
commit
c16eb2bdcc
20
LICENSES/httpure.LICENSE
Normal file
20
LICENSES/httpure.LICENSE
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2017 Connor Prussin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
License
2
License
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2017 Connor Prussin
|
Copyright (c) 2022 Jan Schulte
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
17
Readme.md
17
Readme.md
@ -1,8 +1,6 @@
|
|||||||
# HTTPurple 🪁
|
# HTTPurple 🪁
|
||||||
|
|
||||||
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/sigma-andex/purescript-httpurple/main/License)
|
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/sigma-andex/purescript-httpurple/main/License)
|
||||||
[![Latest release](http://img.shields.io/github/release/sigma-andex/purescript-httpurple.svg)](https://github.com/sigma-andex/purescript-httpurple/releases)
|
|
||||||
[![purescript-httpure on Pursuit](https://pursuit.purescript.org/packages/purescript-httpure/badge)](https://pursuit.purescript.org/packages/purescript-httpure)
|
|
||||||
|
|
||||||
A 🎨 colourful fork of the amazing [HTTPure](https://github.com/citizennet/purescript-httpure) http server framework.
|
A 🎨 colourful fork of the amazing [HTTPure](https://github.com/citizennet/purescript-httpure) http server framework.
|
||||||
|
|
||||||
@ -10,7 +8,7 @@ A 🎨 colourful fork of the amazing [HTTPure](https://github.com/citizennet/pur
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
spago install httpure
|
spago install httpurple
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
@ -21,7 +19,7 @@ module Main where
|
|||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (ServerM, serve, ok)
|
import HTTPurple (ServerM, serve, ok)
|
||||||
|
|
||||||
main :: ServerM
|
main :: ServerM
|
||||||
main = serve 8080 router $ log "Server now up on port 8080"
|
main = serve 8080 router $ log "Server now up on port 8080"
|
||||||
@ -31,18 +29,13 @@ main = serve 8080 router $ log "Server now up on port 8080"
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Module documentation is published
|
See the [docs folder](./docs).
|
||||||
on [Pursuit](http://pursuit.purescript.org/packages/purescript-httpure).
|
|
||||||
|
|
||||||
You can also take a look at [our guides](./docs).
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
HTTPure ships with a number of [examples](./docs/Examples). To run an example,
|
HTTPurple ships with a number of [examples](./docs/Examples). To run an example,
|
||||||
in the project root, run:
|
in the project root, run:
|
||||||
|
|
||||||
Or, without `nix`:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
spago -x test.dhall run --main Examples.<Example Name>.Main
|
spago -x test.dhall run --main Examples.<Example Name>.Main
|
||||||
```
|
```
|
||||||
@ -60,4 +53,4 @@ spago -x test.dhall test
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](./License)
|
This is a fork of [HTTPure](https://github.com/citizennet/purescript-httpure), which is licensed under MIT. See the [original license](./LICENSES/httpure.LICENSE). This work is similarly licensed under [MIT](./License).
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
import Node.FS.Aff (readTextFile)
|
import Node.FS.Aff (readTextFile)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve, toBuffer)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve, toBuffer)
|
||||||
import Node.Buffer (Buffer)
|
import Node.Buffer (Buffer)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Headers, Request, ResponseM, ServerM, header, ok', serve)
|
import HTTPurple (Headers, Request, ResponseM, ServerM, header, ok', serve)
|
||||||
import Node.FS.Aff (readFile)
|
import Node.FS.Aff (readFile)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..))
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
|
||||||
import Node.ChildProcess (defaultSpawnOptions, spawn, stdout)
|
import Node.ChildProcess (defaultSpawnOptions, spawn, stdout)
|
||||||
import Node.Stream (Readable)
|
import Node.Stream (Readable)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
|
@ -8,7 +8,7 @@ import Data.Maybe (Maybe(..))
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Aff.Class (class MonadAff)
|
import Effect.Aff.Class (class MonadAff)
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, Response, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, Response, ResponseM, ServerM, ok, serve)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Headers, Request, ResponseM, ServerM, header, ok', serve, (!@))
|
import HTTPurple (Headers, Request, ResponseM, ServerM, header, ok', serve, (!@))
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (ServerM, ok, serve)
|
import HTTPurple (ServerM, ok, serve)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import Data.Generic.Rep (class Generic)
|
|||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (type (<+>), Request, ResponseM, ServerM, fullPath, header, ok, ok', serve, (<+>))
|
import HTTPurple (type (<+>), Request, ResponseM, ServerM, fullPath, header, ok, ok', serve, (<+>))
|
||||||
import Record as Record
|
import Record as Record
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
@ -5,7 +5,7 @@ import Prelude hiding ((/))
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
|
||||||
import Routing.Duplex (RouteDuplex')
|
import Routing.Duplex (RouteDuplex')
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
|
@ -5,8 +5,8 @@ import Prelude hiding ((/))
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
|
||||||
import Routing.Duplex (RouteDuplex')
|
import Routing.Duplex (RouteDuplex')
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Method(Post), Request, ResponseM, ServerM, notFound, ok, serve, toString)
|
import HTTPurple (Method(Post), Request, ResponseM, ServerM, notFound, ok, serve, toString)
|
||||||
import Routing.Duplex (RouteDuplex')
|
import Routing.Duplex (RouteDuplex')
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Class.Console (log)
|
import Effect.Class.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, notFound, ok, serve)
|
import HTTPurple (Request, ResponseM, ServerM, notFound, ok, serve)
|
||||||
import Routing.Duplex (RouteDuplex')
|
import Routing.Duplex (RouteDuplex')
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
|
@ -5,7 +5,7 @@ import Prelude
|
|||||||
import Data.Generic.Rep (class Generic)
|
import Data.Generic.Rep (class Generic)
|
||||||
import Data.Maybe (Maybe(..))
|
import Data.Maybe (Maybe(..))
|
||||||
import Effect.Console (log)
|
import Effect.Console (log)
|
||||||
import HTTPure (Request, ResponseM, ServerM, ok, serveSecure)
|
import HTTPurple (Request, ResponseM, ServerM, ok, serveSecure)
|
||||||
import Routing.Duplex (RouteDuplex')
|
import Routing.Duplex (RouteDuplex')
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
module HTTPure
|
module HTTPurple
|
||||||
( module HTTPure.Body
|
( module HTTPurple.Body
|
||||||
, module HTTPure.Headers
|
, module HTTPurple.Headers
|
||||||
, module HTTPure.Lookup
|
, module HTTPurple.Lookup
|
||||||
, module HTTPure.Method
|
, module HTTPurple.Method
|
||||||
, module HTTPure.Path
|
, module HTTPurple.Path
|
||||||
, module HTTPure.Routes
|
, module HTTPurple.Routes
|
||||||
, module HTTPure.Query
|
, module HTTPurple.Query
|
||||||
, module HTTPure.Request
|
, module HTTPurple.Request
|
||||||
, module HTTPure.Response
|
, module HTTPurple.Response
|
||||||
, module HTTPure.Server
|
, module HTTPurple.Server
|
||||||
, module HTTPure.Status
|
, module HTTPurple.Status
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import HTTPure.Body (toBuffer, toStream, toString)
|
import HTTPurple.Body (toBuffer, toStream, toString)
|
||||||
import HTTPure.Headers (Headers, empty, header, headers)
|
import HTTPurple.Headers (Headers, empty, header, headers)
|
||||||
import HTTPure.Lookup (at, has, lookup, (!!), (!?), (!@))
|
import HTTPurple.Lookup (at, has, lookup, (!!), (!?), (!@))
|
||||||
import HTTPure.Method (Method(..))
|
import HTTPurple.Method (Method(..))
|
||||||
import HTTPure.Path (Path)
|
import HTTPurple.Path (Path)
|
||||||
import HTTPure.Query (Query)
|
import HTTPurple.Query (Query)
|
||||||
import HTTPure.Request (Request, fullPath)
|
import HTTPurple.Request (Request, fullPath)
|
||||||
import HTTPure.Response (Response, ResponseM, accepted, accepted', alreadyReported, alreadyReported', badGateway, badGateway', badRequest, badRequest', conflict, conflict', continue, continue', created, created', emptyResponse, emptyResponse', expectationFailed, expectationFailed', failedDependency, failedDependency', forbidden, forbidden', found, found', gatewayTimeout, gatewayTimeout', gone, gone', hTTPVersionNotSupported, hTTPVersionNotSupported', iMUsed, iMUsed', imATeapot, imATeapot', insufficientStorage, insufficientStorage', internalServerError, internalServerError', lengthRequired, lengthRequired', locked, locked', loopDetected, loopDetected', methodNotAllowed, methodNotAllowed', misdirectedRequest, misdirectedRequest', movedPermanently, movedPermanently', multiStatus, multiStatus', multipleChoices, multipleChoices', networkAuthenticationRequired, networkAuthenticationRequired', noContent, noContent', nonAuthoritativeInformation, nonAuthoritativeInformation', notAcceptable, notAcceptable', notExtended, notExtended', notFound, notFound', notImplemented, notImplemented', notModified, notModified', ok, ok', partialContent, partialContent', payloadTooLarge, payloadTooLarge', paymentRequired, paymentRequired', permanentRedirect, permanentRedirect', preconditionFailed, preconditionFailed', preconditionRequired, preconditionRequired', processing, processing', proxyAuthenticationRequired, proxyAuthenticationRequired', rangeNotSatisfiable, rangeNotSatisfiable', requestHeaderFieldsTooLarge, requestHeaderFieldsTooLarge', requestTimeout, requestTimeout', resetContent, resetContent', response, response', seeOther, seeOther', serviceUnavailable, serviceUnavailable', switchingProtocols, switchingProtocols', temporaryRedirect, temporaryRedirect', tooManyRequests, tooManyRequests', uRITooLong, uRITooLong', unauthorized, unauthorized', unavailableForLegalReasons, unavailableForLegalReasons', unprocessableEntity, unprocessableEntity', unsupportedMediaType, unsupportedMediaType', upgradeRequired, upgradeRequired', useProxy, useProxy', variantAlsoNegotiates, variantAlsoNegotiates')
|
import HTTPurple.Response (Response, ResponseM, accepted, accepted', alreadyReported, alreadyReported', badGateway, badGateway', badRequest, badRequest', conflict, conflict', continue, continue', created, created', emptyResponse, emptyResponse', expectationFailed, expectationFailed', failedDependency, failedDependency', forbidden, forbidden', found, found', gatewayTimeout, gatewayTimeout', gone, gone', hTTPVersionNotSupported, hTTPVersionNotSupported', iMUsed, iMUsed', imATeapot, imATeapot', insufficientStorage, insufficientStorage', internalServerError, internalServerError', lengthRequired, lengthRequired', locked, locked', loopDetected, loopDetected', methodNotAllowed, methodNotAllowed', misdirectedRequest, misdirectedRequest', movedPermanently, movedPermanently', multiStatus, multiStatus', multipleChoices, multipleChoices', networkAuthenticationRequired, networkAuthenticationRequired', noContent, noContent', nonAuthoritativeInformation, nonAuthoritativeInformation', notAcceptable, notAcceptable', notExtended, notExtended', notFound, notFound', notImplemented, notImplemented', notModified, notModified', ok, ok', partialContent, partialContent', payloadTooLarge, payloadTooLarge', paymentRequired, paymentRequired', permanentRedirect, permanentRedirect', preconditionFailed, preconditionFailed', preconditionRequired, preconditionRequired', processing, processing', proxyAuthenticationRequired, proxyAuthenticationRequired', rangeNotSatisfiable, rangeNotSatisfiable', requestHeaderFieldsTooLarge, requestHeaderFieldsTooLarge', requestTimeout, requestTimeout', resetContent, resetContent', response, response', seeOther, seeOther', serviceUnavailable, serviceUnavailable', switchingProtocols, switchingProtocols', temporaryRedirect, temporaryRedirect', tooManyRequests, tooManyRequests', uRITooLong, uRITooLong', unauthorized, unauthorized', unavailableForLegalReasons, unavailableForLegalReasons', unprocessableEntity, unprocessableEntity', unsupportedMediaType, unsupportedMediaType', upgradeRequired, upgradeRequired', useProxy, useProxy', variantAlsoNegotiates, variantAlsoNegotiates')
|
||||||
import HTTPure.Routes (type (<+>), combineRoutes, (<+>))
|
import HTTPurple.Routes (type (<+>), combineRoutes, (<+>))
|
||||||
import HTTPure.Server (ServerM, serve, serve', serveSecure, serveSecure')
|
import HTTPurple.Server (ServerM, serve, serve', serveSecure, serveSecure')
|
||||||
import HTTPure.Status (Status)
|
import HTTPurple.Status (Status)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Body
|
module HTTPurple.Body
|
||||||
( class Body
|
( class Body
|
||||||
, RequestBody
|
, RequestBody
|
||||||
, defaultHeaders
|
, defaultHeaders
|
||||||
@ -18,7 +18,7 @@ import Effect.Aff (Aff, makeAff, nonCanceler)
|
|||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Ref (Ref)
|
import Effect.Ref (Ref)
|
||||||
import Effect.Ref (modify, new, read, write) as Ref
|
import Effect.Ref (modify, new, read, write) as Ref
|
||||||
import HTTPure.Headers (Headers, header)
|
import HTTPurple.Headers (Headers, header)
|
||||||
import Node.Buffer (Buffer, concat, fromString, size)
|
import Node.Buffer (Buffer, concat, fromString, size)
|
||||||
import Node.Buffer (toString) as Buffer
|
import Node.Buffer (toString) as Buffer
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
@ -95,7 +95,7 @@ toBuffer requestBody = do
|
|||||||
toStream :: RequestBody -> Readable ()
|
toStream :: RequestBody -> Readable ()
|
||||||
toStream = _.stream
|
toStream = _.stream
|
||||||
|
|
||||||
-- | Types that implement the `Body` class can be used as a body to an HTTPure
|
-- | Types that implement the `Body` class can be used as a body to an HTTPurple
|
||||||
-- | response, and can be used with all the response helpers.
|
-- | response, and can be used with all the response helpers.
|
||||||
class Body b where
|
class Body b where
|
||||||
-- | Return any default headers that need to be sent with this body type,
|
-- | Return any default headers that need to be sent with this body type,
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Headers
|
module HTTPurple.Headers
|
||||||
( Headers(..)
|
( Headers(..)
|
||||||
, empty
|
, empty
|
||||||
, headers
|
, headers
|
||||||
@ -19,7 +19,7 @@ import Data.TraversableWithIndex (traverseWithIndex)
|
|||||||
import Data.Tuple (Tuple(Tuple))
|
import Data.Tuple (Tuple(Tuple))
|
||||||
import Effect (Effect)
|
import Effect (Effect)
|
||||||
import Foreign.Object (fold)
|
import Foreign.Object (fold)
|
||||||
import HTTPure.Lookup (class Lookup, (!!))
|
import HTTPurple.Lookup (class Lookup, (!!))
|
||||||
import Node.HTTP (Request, Response, requestHeaders, setHeader)
|
import Node.HTTP (Request, Response, requestHeaders, setHeader)
|
||||||
|
|
||||||
-- | The `Headers` type is just sugar for a `Object` of `Strings`
|
-- | The `Headers` type is just sugar for a `Object` of `Strings`
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Lookup
|
module HTTPurple.Lookup
|
||||||
( class Lookup
|
( class Lookup
|
||||||
, at
|
, at
|
||||||
, (!@)
|
, (!@)
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Method
|
module HTTPurple.Method
|
||||||
( Method(..)
|
( Method(..)
|
||||||
, read
|
, read
|
||||||
) where
|
) where
|
||||||
@ -7,7 +7,7 @@ import Prelude
|
|||||||
|
|
||||||
import Node.HTTP (Request, requestMethod)
|
import Node.HTTP (Request, requestMethod)
|
||||||
|
|
||||||
-- | These are the HTTP methods that HTTPure understands.
|
-- | These are the HTTP methods that HTTPurple understands.
|
||||||
data Method
|
data Method
|
||||||
= Get
|
= Get
|
||||||
| Post
|
| Post
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Path
|
module HTTPurple.Path
|
||||||
( Path
|
( Path
|
||||||
, read
|
, read
|
||||||
) where
|
) where
|
||||||
@ -8,7 +8,7 @@ import Prelude
|
|||||||
import Data.Array (filter, head)
|
import Data.Array (filter, head)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.String (Pattern(Pattern), split)
|
import Data.String (Pattern(Pattern), split)
|
||||||
import HTTPure.Utils (urlDecode)
|
import HTTPurple.Utils (urlDecode)
|
||||||
import Node.HTTP (Request, requestURL)
|
import Node.HTTP (Request, requestURL)
|
||||||
|
|
||||||
-- | The `Path` type is just sugar for an `Array` of `String` segments that are
|
-- | The `Path` type is just sugar for an `Array` of `String` segments that are
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Query
|
module HTTPurple.Query
|
||||||
( Query
|
( Query
|
||||||
, read
|
, read
|
||||||
) where
|
) where
|
||||||
@ -11,7 +11,7 @@ import Data.Maybe (fromMaybe)
|
|||||||
import Data.String (Pattern(Pattern), joinWith, split)
|
import Data.String (Pattern(Pattern), joinWith, split)
|
||||||
import Data.Tuple (Tuple(Tuple))
|
import Data.Tuple (Tuple(Tuple))
|
||||||
import Foreign.Object (Object, fromFoldable)
|
import Foreign.Object (Object, fromFoldable)
|
||||||
import HTTPure.Utils (replacePlus, urlDecode)
|
import HTTPurple.Utils (replacePlus, urlDecode)
|
||||||
import Node.HTTP (Request, requestURL)
|
import Node.HTTP (Request, requestURL)
|
||||||
|
|
||||||
-- | The `Query` type is a `Object` of `Strings`, with one entry per query
|
-- | The `Query` type is a `Object` of `Strings`, with one entry per query
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Request
|
module HTTPurple.Request
|
||||||
( Request
|
( Request
|
||||||
, fromHTTPRequest
|
, fromHTTPRequest
|
||||||
, fullPath
|
, fullPath
|
||||||
@ -12,19 +12,19 @@ import Data.String (joinWith)
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Foreign.Object (isEmpty, toArrayWithKey)
|
import Foreign.Object (isEmpty, toArrayWithKey)
|
||||||
import HTTPure.Body (RequestBody)
|
import HTTPurple.Body (RequestBody)
|
||||||
import HTTPure.Body (read) as Body
|
import HTTPurple.Body (read) as Body
|
||||||
import HTTPure.Headers (Headers)
|
import HTTPurple.Headers (Headers)
|
||||||
import HTTPure.Headers (read) as Headers
|
import HTTPurple.Headers (read) as Headers
|
||||||
import HTTPure.Method (Method)
|
import HTTPurple.Method (Method)
|
||||||
import HTTPure.Method (read) as Method
|
import HTTPurple.Method (read) as Method
|
||||||
import HTTPure.Path (Path)
|
import HTTPurple.Path (Path)
|
||||||
import HTTPure.Path (read) as Path
|
import HTTPurple.Path (read) as Path
|
||||||
import HTTPure.Query (Query)
|
import HTTPurple.Query (Query)
|
||||||
import HTTPure.Query (read) as Query
|
import HTTPurple.Query (read) as Query
|
||||||
import HTTPure.Utils (encodeURIComponent)
|
import HTTPurple.Utils (encodeURIComponent)
|
||||||
import HTTPure.Version (Version)
|
import HTTPurple.Version (Version)
|
||||||
import HTTPure.Version (read) as Version
|
import HTTPurple.Version (read) as Version
|
||||||
import Node.HTTP (Request) as HTTP
|
import Node.HTTP (Request) as HTTP
|
||||||
import Node.HTTP (requestURL)
|
import Node.HTTP (requestURL)
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
@ -54,7 +54,7 @@ fullPath request = "/" <> path <> questionMark <> queryParams
|
|||||||
queryParamsArr = toArrayWithKey stringifyQueryParam request.query
|
queryParamsArr = toArrayWithKey stringifyQueryParam request.query
|
||||||
stringifyQueryParam key value = encodeURIComponent key <> "=" <> encodeURIComponent value
|
stringifyQueryParam key value = encodeURIComponent key <> "=" <> encodeURIComponent value
|
||||||
|
|
||||||
-- | Given an HTTP `Request` object, this method will convert it to an HTTPure
|
-- | Given an HTTP `Request` object, this method will convert it to an HTTPurple
|
||||||
-- | `Request` object.
|
-- | `Request` object.
|
||||||
fromHTTPRequest :: forall route. RD.RouteDuplex' route -> HTTP.Request -> Aff (Either (Request Unit) (Request route))
|
fromHTTPRequest :: forall route. RD.RouteDuplex' route -> HTTP.Request -> Aff (Either (Request Unit) (Request route))
|
||||||
fromHTTPRequest route request = do
|
fromHTTPRequest route request = do
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Response
|
module HTTPurple.Response
|
||||||
( Response
|
( Response
|
||||||
, ResponseM
|
, ResponseM
|
||||||
, send
|
, send
|
||||||
@ -138,11 +138,11 @@ import Prelude
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Aff.Class (class MonadAff, liftAff)
|
import Effect.Aff.Class (class MonadAff, liftAff)
|
||||||
import Effect.Class (class MonadEffect, liftEffect)
|
import Effect.Class (class MonadEffect, liftEffect)
|
||||||
import HTTPure.Body (class Body, defaultHeaders, write)
|
import HTTPurple.Body (class Body, defaultHeaders, write)
|
||||||
import HTTPure.Headers (Headers, empty)
|
import HTTPurple.Headers (Headers, empty)
|
||||||
import HTTPure.Headers (write) as Headers
|
import HTTPurple.Headers (write) as Headers
|
||||||
import HTTPure.Status (Status)
|
import HTTPurple.Status (Status)
|
||||||
import HTTPure.Status
|
import HTTPurple.Status
|
||||||
( accepted
|
( accepted
|
||||||
, alreadyReported
|
, alreadyReported
|
||||||
, badGateway
|
, badGateway
|
||||||
@ -207,7 +207,7 @@ import HTTPure.Status
|
|||||||
) as Status
|
) as Status
|
||||||
import Node.HTTP (Response) as HTTP
|
import Node.HTTP (Response) as HTTP
|
||||||
|
|
||||||
-- | The `ResponseM` type simply conveniently wraps up an HTTPure monad that
|
-- | The `ResponseM` type simply conveniently wraps up an HTTPurple monad that
|
||||||
-- | returns a response. This type is the return type of all router/route
|
-- | returns a response. This type is the return type of all router/route
|
||||||
-- | methods.
|
-- | methods.
|
||||||
type ResponseM = Aff Response
|
type ResponseM = Aff Response
|
||||||
@ -219,8 +219,8 @@ type Response =
|
|||||||
, writeBody :: HTTP.Response -> Aff Unit
|
, writeBody :: HTTP.Response -> Aff Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Given an HTTP `Response` and a HTTPure `Response`, this method will return
|
-- | Given an HTTP `Response` and a HTTPurple `Response`, this method will return
|
||||||
-- | a monad encapsulating writing the HTTPure `Response` to the HTTP `Response`
|
-- | a monad encapsulating writing the HTTPurple `Response` to the HTTP `Response`
|
||||||
-- | and closing the HTTP `Response`.
|
-- | and closing the HTTP `Response`.
|
||||||
send :: forall m. MonadEffect m => MonadAff m => HTTP.Response -> Response -> m Unit
|
send :: forall m. MonadEffect m => MonadAff m => HTTP.Response -> Response -> m Unit
|
||||||
send httpresponse { status, headers, writeBody } = do
|
send httpresponse { status, headers, writeBody } = do
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Routes
|
module HTTPurple.Routes
|
||||||
( (<+>)
|
( (<+>)
|
||||||
, combineRoutes
|
, combineRoutes
|
||||||
, orElse
|
, orElse
|
||||||
@ -10,8 +10,8 @@ import Prelude
|
|||||||
import Control.Alt ((<|>))
|
import Control.Alt ((<|>))
|
||||||
import Data.Either (Either(..))
|
import Data.Either (Either(..))
|
||||||
import Data.Profunctor.Choice ((|||))
|
import Data.Profunctor.Choice ((|||))
|
||||||
import HTTPure.Request (Request)
|
import HTTPurple.Request (Request)
|
||||||
import HTTPure.Response (ResponseM)
|
import HTTPurple.Response (ResponseM)
|
||||||
import Record as Record
|
import Record as Record
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Type.Proxy (Proxy(..))
|
import Type.Proxy (Proxy(..))
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Server
|
module HTTPurple.Server
|
||||||
( ServerM
|
( ServerM
|
||||||
, serve
|
, serve
|
||||||
, serve'
|
, serve'
|
||||||
@ -15,8 +15,8 @@ import Effect (Effect)
|
|||||||
import Effect.Aff (catchError, message, runAff)
|
import Effect.Aff (catchError, message, runAff)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Console (error)
|
import Effect.Console (error)
|
||||||
import HTTPure.Request (Request, fromHTTPRequest)
|
import HTTPurple.Request (Request, fromHTTPRequest)
|
||||||
import HTTPure.Response (ResponseM, internalServerError, notFound, send)
|
import HTTPurple.Response (ResponseM, internalServerError, notFound, send)
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
import Node.FS.Sync (readTextFile)
|
import Node.FS.Sync (readTextFile)
|
||||||
import Node.HTTP (ListenOptions, close, listen)
|
import Node.HTTP (ListenOptions, close, listen)
|
||||||
@ -26,7 +26,7 @@ import Node.HTTP.Secure (createServer) as HTTPS
|
|||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
|
|
||||||
-- | The `ServerM` is just an `Effect` containing a callback to close the
|
-- | The `ServerM` is just an `Effect` containing a callback to close the
|
||||||
-- | server. This type is the return type of the HTTPure serve and related
|
-- | server. This type is the return type of the HTTPurple serve and related
|
||||||
-- | methods.
|
-- | methods.
|
||||||
type ServerM = Effect (Effect Unit -> Effect Unit)
|
type ServerM = Effect (Effect Unit -> Effect Unit)
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ defaultNotFoundHandler = const notFound
|
|||||||
|
|
||||||
-- | Given a `ListenOptions` object, a function mapping `Request` to
|
-- | Given a `ListenOptions` object, a function mapping `Request` to
|
||||||
-- | `ResponseM`, and a `ServerM` containing effects to run on boot, creates and
|
-- | `ResponseM`, and a `ServerM` containing effects to run on boot, creates and
|
||||||
-- | runs a HTTPure server without SSL.
|
-- | runs a HTTPurple server without SSL.
|
||||||
serve' ::
|
serve' ::
|
||||||
forall route.
|
forall route.
|
||||||
ListenOptions ->
|
ListenOptions ->
|
||||||
@ -81,7 +81,7 @@ serve' options { route, router, notFoundHandler } onStarted = do
|
|||||||
|
|
||||||
-- | Given a `Options HTTPS.SSLOptions` object and a `HTTP.ListenOptions`
|
-- | Given a `Options HTTPS.SSLOptions` object and a `HTTP.ListenOptions`
|
||||||
-- | object, a function mapping `Request` to `ResponseM`, and a `ServerM`
|
-- | object, a function mapping `Request` to `ResponseM`, and a `ServerM`
|
||||||
-- | containing effects to run on boot, creates and runs a HTTPure server with
|
-- | containing effects to run on boot, creates and runs a HTTPurple server with
|
||||||
-- | SSL.
|
-- | SSL.
|
||||||
serveSecure' ::
|
serveSecure' ::
|
||||||
forall route.
|
forall route.
|
||||||
@ -103,7 +103,7 @@ listenOptions port =
|
|||||||
, backlog: Nothing
|
, backlog: Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Create and start a server. This is the main entry point for HTTPure. Takes
|
-- | Create and start a server. This is the main entry point for HTTPurple. Takes
|
||||||
-- | a port number on which to listen, a function mapping `Request` to
|
-- | a port number on which to listen, a function mapping `Request` to
|
||||||
-- | `ResponseM`, and a `ServerM` containing effects to run after the server has
|
-- | `ResponseM`, and a `ServerM` containing effects to run after the server has
|
||||||
-- | booted (usually logging). Returns an `ServerM` containing the server's
|
-- | booted (usually logging). Returns an `ServerM` containing the server's
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Status
|
module HTTPurple.Status
|
||||||
( Status
|
( Status
|
||||||
, write
|
, write
|
||||||
-- 1xx
|
-- 1xx
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Utils
|
module HTTPurple.Utils
|
||||||
( encodeURIComponent
|
( encodeURIComponent
|
||||||
, replacePlus
|
, replacePlus
|
||||||
, urlDecode
|
, urlDecode
|
@ -1,4 +1,4 @@
|
|||||||
module HTTPure.Version
|
module HTTPurple.Version
|
||||||
( Version(..)
|
( Version(..)
|
||||||
, read
|
, read
|
||||||
) where
|
) where
|
||||||
@ -7,7 +7,7 @@ import Prelude
|
|||||||
|
|
||||||
import Node.HTTP (Request, httpVersion)
|
import Node.HTTP (Request, httpVersion)
|
||||||
|
|
||||||
-- | These are the HTTP versions that HTTPure understands. There are five
|
-- | These are the HTTP versions that HTTPurple understands. There are five
|
||||||
-- | commonly known versions which are explicitly named.
|
-- | commonly known versions which are explicitly named.
|
||||||
data Version
|
data Version
|
||||||
= HTTP0_9
|
= HTTP0_9
|
@ -1,4 +1,4 @@
|
|||||||
module Test.HTTPure.BodySpec where
|
module Test.HTTPurple.BodySpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
@ -6,13 +6,13 @@ import Data.Maybe (Maybe(Nothing), fromMaybe)
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Ref (new) as Ref
|
import Effect.Ref (new) as Ref
|
||||||
import HTTPure.Body (RequestBody, defaultHeaders, read, toBuffer, toStream, toString, write)
|
import HTTPurple.Body (RequestBody, defaultHeaders, read, toBuffer, toStream, toString, write)
|
||||||
import HTTPure.Headers (header)
|
import HTTPurple.Headers (header)
|
||||||
import Node.Buffer (Buffer, fromString)
|
import Node.Buffer (Buffer, fromString)
|
||||||
import Node.Buffer (toString) as Buffer
|
import Node.Buffer (toString) as Buffer
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
import Node.Stream (readString)
|
import Node.Stream (readString)
|
||||||
import Test.HTTPure.TestHelpers (Test, getResponseBody, mockRequest, mockResponse, stringToStream, (?=))
|
import Test.HTTPurple.TestHelpers (Test, getResponseBody, mockRequest, mockResponse, stringToStream, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
mockRequestBody :: String -> Aff RequestBody
|
mockRequestBody :: String -> Aff RequestBody
|
@ -1,14 +1,14 @@
|
|||||||
module Test.HTTPure.HeadersSpec where
|
module Test.HTTPurple.HeadersSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Maybe (Maybe(Nothing, Just))
|
import Data.Maybe (Maybe(Nothing, Just))
|
||||||
import Data.Tuple (Tuple(Tuple))
|
import Data.Tuple (Tuple(Tuple))
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import HTTPure.Headers (empty, header, headers, read, write)
|
import HTTPurple.Headers (empty, header, headers, read, write)
|
||||||
import HTTPure.Lookup ((!!))
|
import HTTPurple.Lookup ((!!))
|
||||||
import Test.HTTPure.TestHelpers ((?=))
|
import Test.HTTPurple.TestHelpers ((?=))
|
||||||
import Test.HTTPure.TestHelpers as TestHelpers
|
import Test.HTTPurple.TestHelpers as TestHelpers
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
lookupSpec :: TestHelpers.Test
|
lookupSpec :: TestHelpers.Test
|
@ -1,4 +1,4 @@
|
|||||||
module Test.HTTPure.IntegrationSpec where
|
module Test.HTTPurple.IntegrationSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import Examples.SSL.Main as SSL
|
|||||||
import Foreign.Object (empty, singleton)
|
import Foreign.Object (empty, singleton)
|
||||||
import Node.Buffer (toArray)
|
import Node.Buffer (toArray)
|
||||||
import Node.FS.Aff (readFile)
|
import Node.FS.Aff (readFile)
|
||||||
import Test.HTTPure.TestHelpers
|
import Test.HTTPurple.TestHelpers
|
||||||
( Test
|
( Test
|
||||||
, get
|
, get
|
||||||
, get'
|
, get'
|
@ -1,11 +1,11 @@
|
|||||||
module Test.HTTPure.LookupSpec where
|
module Test.HTTPurple.LookupSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Maybe (Maybe(Nothing, Just))
|
import Data.Maybe (Maybe(Nothing, Just))
|
||||||
import Foreign.Object (singleton)
|
import Foreign.Object (singleton)
|
||||||
import HTTPure.Lookup ((!!), (!?), (!@))
|
import HTTPurple.Lookup ((!!), (!?), (!@))
|
||||||
import Test.HTTPure.TestHelpers (Test, (?=))
|
import Test.HTTPurple.TestHelpers (Test, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
atSpec :: Test
|
atSpec :: Test
|
@ -1,12 +1,12 @@
|
|||||||
module Test.HTTPure.MethodSpec where
|
module Test.HTTPurple.MethodSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import HTTPure.Method
|
import HTTPurple.Method
|
||||||
( Method(Get, Post, Put, Delete, Head, Connect, Options, Trace, Patch)
|
( Method(Get, Post, Put, Delete, Head, Connect, Options, Trace, Patch)
|
||||||
, read
|
, read
|
||||||
)
|
)
|
||||||
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
showSpec :: Test
|
showSpec :: Test
|
@ -1,9 +1,9 @@
|
|||||||
module Test.HTTPure.PathSpec where
|
module Test.HTTPurple.PathSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import HTTPure.Path (read)
|
import HTTPurple.Path (read)
|
||||||
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
readSpec :: Test
|
readSpec :: Test
|
@ -1,11 +1,11 @@
|
|||||||
module Test.HTTPure.QuerySpec where
|
module Test.HTTPurple.QuerySpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Tuple (Tuple(Tuple))
|
import Data.Tuple (Tuple(Tuple))
|
||||||
import Foreign.Object (empty, fromFoldable, singleton)
|
import Foreign.Object (empty, fromFoldable, singleton)
|
||||||
import HTTPure.Query (read)
|
import HTTPurple.Query (read)
|
||||||
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
readSpec :: Test
|
readSpec :: Test
|
@ -1,4 +1,4 @@
|
|||||||
module Test.HTTPure.RequestSpec where
|
module Test.HTTPurple.RequestSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
@ -11,15 +11,15 @@ import Data.Tuple (Tuple(Tuple))
|
|||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Effect.Exception (error)
|
import Effect.Exception (error)
|
||||||
import Foreign.Object (singleton)
|
import Foreign.Object (singleton)
|
||||||
import HTTPure.Body (toString)
|
import HTTPurple.Body (toString)
|
||||||
import HTTPure.Headers (headers)
|
import HTTPurple.Headers (headers)
|
||||||
import HTTPure.Method (Method(Post))
|
import HTTPurple.Method (Method(Post))
|
||||||
import HTTPure.Request (fromHTTPRequest, fullPath)
|
import HTTPurple.Request (fromHTTPRequest, fullPath)
|
||||||
import HTTPure.Version (Version(HTTP1_1))
|
import HTTPurple.Version (Version(HTTP1_1))
|
||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
import Routing.Duplex.Generic.Syntax ((?))
|
import Routing.Duplex.Generic.Syntax ((?))
|
||||||
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
data Route = Test { a :: Maybe String }
|
data Route = Test { a :: Maybe String }
|
@ -1,17 +1,17 @@
|
|||||||
module Test.HTTPure.ResponseSpec where
|
module Test.HTTPurple.ResponseSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Data.Either (Either(Right))
|
import Data.Either (Either(Right))
|
||||||
import Effect.Aff (makeAff, nonCanceler)
|
import Effect.Aff (makeAff, nonCanceler)
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import HTTPure.Body (defaultHeaders)
|
import HTTPurple.Body (defaultHeaders)
|
||||||
import HTTPure.Headers (header)
|
import HTTPurple.Headers (header)
|
||||||
import HTTPure.Response (emptyResponse, emptyResponse', response, response', send)
|
import HTTPurple.Response (emptyResponse, emptyResponse', response, response', send)
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
import Node.HTTP (responseAsStream)
|
import Node.HTTP (responseAsStream)
|
||||||
import Node.Stream (end, writeString)
|
import Node.Stream (end, writeString)
|
||||||
import Test.HTTPure.TestHelpers
|
import Test.HTTPurple.TestHelpers
|
||||||
( Test
|
( Test
|
||||||
, getResponseBody
|
, getResponseBody
|
||||||
, getResponseHeader
|
, getResponseHeader
|
@ -1,4 +1,4 @@
|
|||||||
module Test.HTTPure.ServerSpec where
|
module Test.HTTPurple.ServerSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
@ -10,9 +10,9 @@ import Data.Options ((:=))
|
|||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Exception (error)
|
import Effect.Exception (error)
|
||||||
import Foreign.Object (empty)
|
import Foreign.Object (empty)
|
||||||
import HTTPure.Request (Request)
|
import HTTPurple.Request (Request)
|
||||||
import HTTPure.Response (ResponseM, notFound, ok)
|
import HTTPurple.Response (ResponseM, notFound, ok)
|
||||||
import HTTPure.Server (serve, serve', serveSecure, serveSecure')
|
import HTTPurple.Server (serve, serve', serveSecure, serveSecure')
|
||||||
import Node.Encoding (Encoding(UTF8))
|
import Node.Encoding (Encoding(UTF8))
|
||||||
import Node.FS.Sync (readTextFile)
|
import Node.FS.Sync (readTextFile)
|
||||||
import Node.HTTP.Secure (key, keyString, cert, certString)
|
import Node.HTTP.Secure (key, keyString, cert, certString)
|
||||||
@ -20,7 +20,7 @@ import Routing.Duplex (RouteDuplex')
|
|||||||
import Routing.Duplex as RD
|
import Routing.Duplex as RD
|
||||||
import Routing.Duplex.Generic as G
|
import Routing.Duplex.Generic as G
|
||||||
import Routing.Duplex.Generic as RG
|
import Routing.Duplex.Generic as RG
|
||||||
import Test.HTTPure.TestHelpers (Test, (?=), get, get', getStatus)
|
import Test.HTTPurple.TestHelpers (Test, (?=), get, get', getStatus)
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
import Test.Spec.Assertions (expectError)
|
import Test.Spec.Assertions (expectError)
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
module Test.HTTPure.StatusSpec where
|
module Test.HTTPurple.StatusSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import HTTPure.Status (write)
|
import HTTPurple.Status (write)
|
||||||
import Test.HTTPure.TestHelpers (Test, getResponseStatus, mockResponse, (?=))
|
import Test.HTTPurple.TestHelpers (Test, getResponseStatus, mockResponse, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
writeSpec :: Test
|
writeSpec :: Test
|
@ -1,4 +1,4 @@
|
|||||||
module Test.HTTPure.TestHelpers where
|
module Test.HTTPurple.TestHelpers where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
module Test.HTTPure.UtilsSpec where
|
module Test.HTTPurple.UtilsSpec where
|
||||||
|
|
||||||
import HTTPure.Utils (replacePlus)
|
import HTTPurple.Utils (replacePlus)
|
||||||
import Test.HTTPure.TestHelpers (Test, (?=))
|
import Test.HTTPurple.TestHelpers (Test, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
replacePlusSpec :: Test
|
replacePlusSpec :: Test
|
@ -1,12 +1,12 @@
|
|||||||
module Test.HTTPure.VersionSpec where
|
module Test.HTTPurple.VersionSpec where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import HTTPure.Version
|
import HTTPurple.Version
|
||||||
( Version(HTTP0_9, HTTP1_0, HTTP1_1, HTTP2_0, HTTP3_0, Other)
|
( Version(HTTP0_9, HTTP1_0, HTTP1_1, HTTP2_0, HTTP3_0, Other)
|
||||||
, read
|
, read
|
||||||
)
|
)
|
||||||
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
|
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
|
||||||
import Test.Spec (describe, it)
|
import Test.Spec (describe, it)
|
||||||
|
|
||||||
showSpec :: Test
|
showSpec :: Test
|
@ -3,26 +3,26 @@ module Test.Main where
|
|||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Effect.Aff (launchAff_)
|
import Effect.Aff (launchAff_)
|
||||||
import Test.HTTPure.BodySpec (bodySpec)
|
import Test.HTTPurple.BodySpec (bodySpec)
|
||||||
import Test.HTTPure.HeadersSpec (headersSpec)
|
import Test.HTTPurple.HeadersSpec (headersSpec)
|
||||||
import Test.HTTPure.IntegrationSpec (integrationSpec)
|
import Test.HTTPurple.IntegrationSpec (integrationSpec)
|
||||||
import Test.HTTPure.LookupSpec (lookupSpec)
|
import Test.HTTPurple.LookupSpec (lookupSpec)
|
||||||
import Test.HTTPure.MethodSpec (methodSpec)
|
import Test.HTTPurple.MethodSpec (methodSpec)
|
||||||
import Test.HTTPure.PathSpec (pathSpec)
|
import Test.HTTPurple.PathSpec (pathSpec)
|
||||||
import Test.HTTPure.QuerySpec (querySpec)
|
import Test.HTTPurple.QuerySpec (querySpec)
|
||||||
import Test.HTTPure.RequestSpec (requestSpec)
|
import Test.HTTPurple.RequestSpec (requestSpec)
|
||||||
import Test.HTTPure.ResponseSpec (responseSpec)
|
import Test.HTTPurple.ResponseSpec (responseSpec)
|
||||||
import Test.HTTPure.ServerSpec (serverSpec)
|
import Test.HTTPurple.ServerSpec (serverSpec)
|
||||||
import Test.HTTPure.StatusSpec (statusSpec)
|
import Test.HTTPurple.StatusSpec (statusSpec)
|
||||||
import Test.HTTPure.TestHelpers (TestSuite)
|
import Test.HTTPurple.TestHelpers (TestSuite)
|
||||||
import Test.HTTPure.UtilsSpec (utilsSpec)
|
import Test.HTTPurple.UtilsSpec (utilsSpec)
|
||||||
import Test.HTTPure.VersionSpec (versionSpec)
|
import Test.HTTPurple.VersionSpec (versionSpec)
|
||||||
import Test.Spec (describe)
|
import Test.Spec (describe)
|
||||||
import Test.Spec.Reporter (specReporter)
|
import Test.Spec.Reporter (specReporter)
|
||||||
import Test.Spec.Runner (runSpec)
|
import Test.Spec.Runner (runSpec)
|
||||||
|
|
||||||
main :: TestSuite
|
main :: TestSuite
|
||||||
main = launchAff_ $ runSpec [ specReporter ] $ describe "HTTPure" do
|
main = launchAff_ $ runSpec [ specReporter ] $ describe "HTTPurple" do
|
||||||
bodySpec
|
bodySpec
|
||||||
headersSpec
|
headersSpec
|
||||||
lookupSpec
|
lookupSpec
|
||||||
|
Loading…
Reference in New Issue
Block a user