Rename modules and rudimentarily update readme

This commit is contained in:
sigma-andex 2022-05-22 12:47:58 +01:00
parent dc245bbfc7
commit c16eb2bdcc
46 changed files with 178 additions and 165 deletions

20
LICENSES/httpure.LICENSE Normal file
View 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.

View File

@ -1,6 +1,6 @@
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
this software and associated documentation files (the "Software"), to deal in

View File

@ -1,8 +1,6 @@
# HTTPurple 🪁
[![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.
@ -10,7 +8,7 @@ A 🎨 colourful fork of the amazing [HTTPure](https://github.com/citizennet/pur
## Installation
```bash
spago install httpure
spago install httpurple
```
## Quick Start
@ -21,7 +19,7 @@ module Main where
import Prelude
import Effect.Console (log)
import HTTPure (ServerM, serve, ok)
import HTTPurple (ServerM, serve, ok)
main :: ServerM
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
Module documentation is published
on [Pursuit](http://pursuit.purescript.org/packages/purescript-httpure).
You can also take a look at [our guides](./docs).
See the [docs folder](./docs).
## 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:
Or, without `nix`:
```bash
spago -x test.dhall run --main Examples.<Example Name>.Main
```
@ -60,4 +53,4 @@ spago -x test.dhall test
## 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).

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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.FS.Aff (readTextFile)
import Routing.Duplex as RD

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 Routing.Duplex as RD
import Routing.Duplex.Generic as RG

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 Routing.Duplex as RD
import Routing.Duplex.Generic as RG

View File

@ -7,7 +7,7 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
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.Stream (Readable)
import Routing.Duplex as RD

View File

@ -8,7 +8,7 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Effect.Aff.Class (class MonadAff)
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.Generic as RG

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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.Generic as RG

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Effect.Console (log)
import HTTPure (ServerM, ok, serve)
import HTTPurple (ServerM, ok, serve)
import Routing.Duplex as RD
import Routing.Duplex.Generic as RG

View File

@ -7,7 +7,7 @@ import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Effect.Class (liftEffect)
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 Routing.Duplex as RD
import Routing.Duplex.Generic as RG

View File

@ -5,7 +5,7 @@ import Prelude hiding ((/))
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 as RD
import Routing.Duplex.Generic as RG

View File

@ -5,8 +5,8 @@ import Prelude hiding ((/))
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Effect.Console (log)
import HTTPure (Request, ResponseM, ServerM, ok, serve)
import HTTPure (Request, ResponseM, ServerM, ok, serve)
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
import HTTPurple (Request, ResponseM, ServerM, ok, serve)
import Routing.Duplex (RouteDuplex')
import Routing.Duplex as RD
import Routing.Duplex.Generic as G

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 as RD
import Routing.Duplex.Generic as G

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 as RD
import Routing.Duplex.Generic as G

View File

@ -5,7 +5,7 @@ import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
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 as RD
import Routing.Duplex.Generic as G

View File

@ -1,25 +1,25 @@
module HTTPure
( module HTTPure.Body
, module HTTPure.Headers
, module HTTPure.Lookup
, module HTTPure.Method
, module HTTPure.Path
, module HTTPure.Routes
, module HTTPure.Query
, module HTTPure.Request
, module HTTPure.Response
, module HTTPure.Server
, module HTTPure.Status
module HTTPurple
( module HTTPurple.Body
, module HTTPurple.Headers
, module HTTPurple.Lookup
, module HTTPurple.Method
, module HTTPurple.Path
, module HTTPurple.Routes
, module HTTPurple.Query
, module HTTPurple.Request
, module HTTPurple.Response
, module HTTPurple.Server
, module HTTPurple.Status
) where
import HTTPure.Body (toBuffer, toStream, toString)
import HTTPure.Headers (Headers, empty, header, headers)
import HTTPure.Lookup (at, has, lookup, (!!), (!?), (!@))
import HTTPure.Method (Method(..))
import HTTPure.Path (Path)
import HTTPure.Query (Query)
import HTTPure.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 HTTPure.Routes (type (<+>), combineRoutes, (<+>))
import HTTPure.Server (ServerM, serve, serve', serveSecure, serveSecure')
import HTTPure.Status (Status)
import HTTPurple.Body (toBuffer, toStream, toString)
import HTTPurple.Headers (Headers, empty, header, headers)
import HTTPurple.Lookup (at, has, lookup, (!!), (!?), (!@))
import HTTPurple.Method (Method(..))
import HTTPurple.Path (Path)
import HTTPurple.Query (Query)
import HTTPurple.Request (Request, fullPath)
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 HTTPurple.Routes (type (<+>), combineRoutes, (<+>))
import HTTPurple.Server (ServerM, serve, serve', serveSecure, serveSecure')
import HTTPurple.Status (Status)

View File

@ -1,4 +1,4 @@
module HTTPure.Body
module HTTPurple.Body
( class Body
, RequestBody
, defaultHeaders
@ -18,7 +18,7 @@ import Effect.Aff (Aff, makeAff, nonCanceler)
import Effect.Class (liftEffect)
import Effect.Ref (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 (toString) as Buffer
import Node.Encoding (Encoding(UTF8))
@ -95,7 +95,7 @@ toBuffer requestBody = do
toStream :: RequestBody -> Readable ()
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.
class Body b where
-- | Return any default headers that need to be sent with this body type,

View File

@ -1,4 +1,4 @@
module HTTPure.Headers
module HTTPurple.Headers
( Headers(..)
, empty
, headers
@ -19,7 +19,7 @@ import Data.TraversableWithIndex (traverseWithIndex)
import Data.Tuple (Tuple(Tuple))
import Effect (Effect)
import Foreign.Object (fold)
import HTTPure.Lookup (class Lookup, (!!))
import HTTPurple.Lookup (class Lookup, (!!))
import Node.HTTP (Request, Response, requestHeaders, setHeader)
-- | The `Headers` type is just sugar for a `Object` of `Strings`

View File

@ -1,4 +1,4 @@
module HTTPure.Lookup
module HTTPurple.Lookup
( class Lookup
, at
, (!@)

View File

@ -1,4 +1,4 @@
module HTTPure.Method
module HTTPurple.Method
( Method(..)
, read
) where
@ -7,7 +7,7 @@ import Prelude
import Node.HTTP (Request, requestMethod)
-- | These are the HTTP methods that HTTPure understands.
-- | These are the HTTP methods that HTTPurple understands.
data Method
= Get
| Post

View File

@ -1,4 +1,4 @@
module HTTPure.Path
module HTTPurple.Path
( Path
, read
) where
@ -8,7 +8,7 @@ import Prelude
import Data.Array (filter, head)
import Data.Maybe (fromMaybe)
import Data.String (Pattern(Pattern), split)
import HTTPure.Utils (urlDecode)
import HTTPurple.Utils (urlDecode)
import Node.HTTP (Request, requestURL)
-- | The `Path` type is just sugar for an `Array` of `String` segments that are

View File

@ -1,4 +1,4 @@
module HTTPure.Query
module HTTPurple.Query
( Query
, read
) where
@ -11,7 +11,7 @@ import Data.Maybe (fromMaybe)
import Data.String (Pattern(Pattern), joinWith, split)
import Data.Tuple (Tuple(Tuple))
import Foreign.Object (Object, fromFoldable)
import HTTPure.Utils (replacePlus, urlDecode)
import HTTPurple.Utils (replacePlus, urlDecode)
import Node.HTTP (Request, requestURL)
-- | The `Query` type is a `Object` of `Strings`, with one entry per query

View File

@ -1,4 +1,4 @@
module HTTPure.Request
module HTTPurple.Request
( Request
, fromHTTPRequest
, fullPath
@ -12,19 +12,19 @@ import Data.String (joinWith)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign.Object (isEmpty, toArrayWithKey)
import HTTPure.Body (RequestBody)
import HTTPure.Body (read) as Body
import HTTPure.Headers (Headers)
import HTTPure.Headers (read) as Headers
import HTTPure.Method (Method)
import HTTPure.Method (read) as Method
import HTTPure.Path (Path)
import HTTPure.Path (read) as Path
import HTTPure.Query (Query)
import HTTPure.Query (read) as Query
import HTTPure.Utils (encodeURIComponent)
import HTTPure.Version (Version)
import HTTPure.Version (read) as Version
import HTTPurple.Body (RequestBody)
import HTTPurple.Body (read) as Body
import HTTPurple.Headers (Headers)
import HTTPurple.Headers (read) as Headers
import HTTPurple.Method (Method)
import HTTPurple.Method (read) as Method
import HTTPurple.Path (Path)
import HTTPurple.Path (read) as Path
import HTTPurple.Query (Query)
import HTTPurple.Query (read) as Query
import HTTPurple.Utils (encodeURIComponent)
import HTTPurple.Version (Version)
import HTTPurple.Version (read) as Version
import Node.HTTP (Request) as HTTP
import Node.HTTP (requestURL)
import Routing.Duplex as RD
@ -54,7 +54,7 @@ fullPath request = "/" <> path <> questionMark <> queryParams
queryParamsArr = toArrayWithKey stringifyQueryParam request.query
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.
fromHTTPRequest :: forall route. RD.RouteDuplex' route -> HTTP.Request -> Aff (Either (Request Unit) (Request route))
fromHTTPRequest route request = do

View File

@ -1,4 +1,4 @@
module HTTPure.Response
module HTTPurple.Response
( Response
, ResponseM
, send
@ -138,11 +138,11 @@ import Prelude
import Effect.Aff (Aff)
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (class MonadEffect, liftEffect)
import HTTPure.Body (class Body, defaultHeaders, write)
import HTTPure.Headers (Headers, empty)
import HTTPure.Headers (write) as Headers
import HTTPure.Status (Status)
import HTTPure.Status
import HTTPurple.Body (class Body, defaultHeaders, write)
import HTTPurple.Headers (Headers, empty)
import HTTPurple.Headers (write) as Headers
import HTTPurple.Status (Status)
import HTTPurple.Status
( accepted
, alreadyReported
, badGateway
@ -207,7 +207,7 @@ import HTTPure.Status
) as Status
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
-- | methods.
type ResponseM = Aff Response
@ -219,8 +219,8 @@ type Response =
, writeBody :: HTTP.Response -> Aff Unit
}
-- | Given an HTTP `Response` and a HTTPure `Response`, this method will return
-- | a monad encapsulating writing the HTTPure `Response` to the HTTP `Response`
-- | Given an HTTP `Response` and a HTTPurple `Response`, this method will return
-- | a monad encapsulating writing the HTTPurple `Response` to the HTTP `Response`
-- | and closing the HTTP `Response`.
send :: forall m. MonadEffect m => MonadAff m => HTTP.Response -> Response -> m Unit
send httpresponse { status, headers, writeBody } = do

View File

@ -1,4 +1,4 @@
module HTTPure.Routes
module HTTPurple.Routes
( (<+>)
, combineRoutes
, orElse
@ -10,8 +10,8 @@ import Prelude
import Control.Alt ((<|>))
import Data.Either (Either(..))
import Data.Profunctor.Choice ((|||))
import HTTPure.Request (Request)
import HTTPure.Response (ResponseM)
import HTTPurple.Request (Request)
import HTTPurple.Response (ResponseM)
import Record as Record
import Routing.Duplex as RD
import Type.Proxy (Proxy(..))

View File

@ -1,4 +1,4 @@
module HTTPure.Server
module HTTPurple.Server
( ServerM
, serve
, serve'
@ -15,8 +15,8 @@ import Effect (Effect)
import Effect.Aff (catchError, message, runAff)
import Effect.Class (liftEffect)
import Effect.Console (error)
import HTTPure.Request (Request, fromHTTPRequest)
import HTTPure.Response (ResponseM, internalServerError, notFound, send)
import HTTPurple.Request (Request, fromHTTPRequest)
import HTTPurple.Response (ResponseM, internalServerError, notFound, send)
import Node.Encoding (Encoding(UTF8))
import Node.FS.Sync (readTextFile)
import Node.HTTP (ListenOptions, close, listen)
@ -26,7 +26,7 @@ import Node.HTTP.Secure (createServer) as HTTPS
import Routing.Duplex as RD
-- | 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.
type ServerM = Effect (Effect Unit -> Effect Unit)
@ -67,7 +67,7 @@ defaultNotFoundHandler = const notFound
-- | Given a `ListenOptions` object, a function mapping `Request` to
-- | `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' ::
forall route.
ListenOptions ->
@ -81,7 +81,7 @@ serve' options { route, router, notFoundHandler } onStarted = do
-- | Given a `Options HTTPS.SSLOptions` object and a `HTTP.ListenOptions`
-- | 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.
serveSecure' ::
forall route.
@ -103,7 +103,7 @@ listenOptions port =
, 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
-- | `ResponseM`, and a `ServerM` containing effects to run after the server has
-- | booted (usually logging). Returns an `ServerM` containing the server's

View File

@ -1,4 +1,4 @@
module HTTPure.Status
module HTTPurple.Status
( Status
, write
-- 1xx

View File

@ -1,4 +1,4 @@
module HTTPure.Utils
module HTTPurple.Utils
( encodeURIComponent
, replacePlus
, urlDecode

View File

@ -1,4 +1,4 @@
module HTTPure.Version
module HTTPurple.Version
( Version(..)
, read
) where
@ -7,7 +7,7 @@ import Prelude
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.
data Version
= HTTP0_9

View File

@ -1,4 +1,4 @@
module Test.HTTPure.BodySpec where
module Test.HTTPurple.BodySpec where
import Prelude
@ -6,13 +6,13 @@ import Data.Maybe (Maybe(Nothing), fromMaybe)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Ref (new) as Ref
import HTTPure.Body (RequestBody, defaultHeaders, read, toBuffer, toStream, toString, write)
import HTTPure.Headers (header)
import HTTPurple.Body (RequestBody, defaultHeaders, read, toBuffer, toStream, toString, write)
import HTTPurple.Headers (header)
import Node.Buffer (Buffer, fromString)
import Node.Buffer (toString) as Buffer
import Node.Encoding (Encoding(UTF8))
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)
mockRequestBody :: String -> Aff RequestBody

View File

@ -1,14 +1,14 @@
module Test.HTTPure.HeadersSpec where
module Test.HTTPurple.HeadersSpec where
import Prelude
import Data.Maybe (Maybe(Nothing, Just))
import Data.Tuple (Tuple(Tuple))
import Effect.Class (liftEffect)
import HTTPure.Headers (empty, header, headers, read, write)
import HTTPure.Lookup ((!!))
import Test.HTTPure.TestHelpers ((?=))
import Test.HTTPure.TestHelpers as TestHelpers
import HTTPurple.Headers (empty, header, headers, read, write)
import HTTPurple.Lookup ((!!))
import Test.HTTPurple.TestHelpers ((?=))
import Test.HTTPurple.TestHelpers as TestHelpers
import Test.Spec (describe, it)
lookupSpec :: TestHelpers.Test

View File

@ -1,4 +1,4 @@
module Test.HTTPure.IntegrationSpec where
module Test.HTTPurple.IntegrationSpec where
import Prelude
@ -19,7 +19,7 @@ import Examples.SSL.Main as SSL
import Foreign.Object (empty, singleton)
import Node.Buffer (toArray)
import Node.FS.Aff (readFile)
import Test.HTTPure.TestHelpers
import Test.HTTPurple.TestHelpers
( Test
, get
, get'

View File

@ -1,11 +1,11 @@
module Test.HTTPure.LookupSpec where
module Test.HTTPurple.LookupSpec where
import Prelude
import Data.Maybe (Maybe(Nothing, Just))
import Foreign.Object (singleton)
import HTTPure.Lookup ((!!), (!?), (!@))
import Test.HTTPure.TestHelpers (Test, (?=))
import HTTPurple.Lookup ((!!), (!?), (!@))
import Test.HTTPurple.TestHelpers (Test, (?=))
import Test.Spec (describe, it)
atSpec :: Test

View File

@ -1,12 +1,12 @@
module Test.HTTPure.MethodSpec where
module Test.HTTPurple.MethodSpec where
import Prelude
import HTTPure.Method
import HTTPurple.Method
( Method(Get, Post, Put, Delete, Head, Connect, Options, Trace, Patch)
, read
)
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
showSpec :: Test

View File

@ -1,9 +1,9 @@
module Test.HTTPure.PathSpec where
module Test.HTTPurple.PathSpec where
import Prelude
import HTTPure.Path (read)
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import HTTPurple.Path (read)
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
readSpec :: Test

View File

@ -1,11 +1,11 @@
module Test.HTTPure.QuerySpec where
module Test.HTTPurple.QuerySpec where
import Prelude
import Data.Tuple (Tuple(Tuple))
import Foreign.Object (empty, fromFoldable, singleton)
import HTTPure.Query (read)
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import HTTPurple.Query (read)
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
readSpec :: Test

View File

@ -1,4 +1,4 @@
module Test.HTTPure.RequestSpec where
module Test.HTTPurple.RequestSpec where
import Prelude
@ -11,15 +11,15 @@ import Data.Tuple (Tuple(Tuple))
import Effect.Aff (Aff)
import Effect.Exception (error)
import Foreign.Object (singleton)
import HTTPure.Body (toString)
import HTTPure.Headers (headers)
import HTTPure.Method (Method(Post))
import HTTPure.Request (fromHTTPRequest, fullPath)
import HTTPure.Version (Version(HTTP1_1))
import HTTPurple.Body (toString)
import HTTPurple.Headers (headers)
import HTTPurple.Method (Method(Post))
import HTTPurple.Request (fromHTTPRequest, fullPath)
import HTTPurple.Version (Version(HTTP1_1))
import Routing.Duplex as RD
import Routing.Duplex.Generic as G
import Routing.Duplex.Generic.Syntax ((?))
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
data Route = Test { a :: Maybe String }

View File

@ -1,17 +1,17 @@
module Test.HTTPure.ResponseSpec where
module Test.HTTPurple.ResponseSpec where
import Prelude
import Data.Either (Either(Right))
import Effect.Aff (makeAff, nonCanceler)
import Effect.Class (liftEffect)
import HTTPure.Body (defaultHeaders)
import HTTPure.Headers (header)
import HTTPure.Response (emptyResponse, emptyResponse', response, response', send)
import HTTPurple.Body (defaultHeaders)
import HTTPurple.Headers (header)
import HTTPurple.Response (emptyResponse, emptyResponse', response, response', send)
import Node.Encoding (Encoding(UTF8))
import Node.HTTP (responseAsStream)
import Node.Stream (end, writeString)
import Test.HTTPure.TestHelpers
import Test.HTTPurple.TestHelpers
( Test
, getResponseBody
, getResponseHeader

View File

@ -1,4 +1,4 @@
module Test.HTTPure.ServerSpec where
module Test.HTTPurple.ServerSpec where
import Prelude
@ -10,9 +10,9 @@ import Data.Options ((:=))
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Foreign.Object (empty)
import HTTPure.Request (Request)
import HTTPure.Response (ResponseM, notFound, ok)
import HTTPure.Server (serve, serve', serveSecure, serveSecure')
import HTTPurple.Request (Request)
import HTTPurple.Response (ResponseM, notFound, ok)
import HTTPurple.Server (serve, serve', serveSecure, serveSecure')
import Node.Encoding (Encoding(UTF8))
import Node.FS.Sync (readTextFile)
import Node.HTTP.Secure (key, keyString, cert, certString)
@ -20,7 +20,7 @@ import Routing.Duplex (RouteDuplex')
import Routing.Duplex as RD
import Routing.Duplex.Generic as G
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.Assertions (expectError)

View File

@ -1,10 +1,10 @@
module Test.HTTPure.StatusSpec where
module Test.HTTPurple.StatusSpec where
import Prelude
import Effect.Class (liftEffect)
import HTTPure.Status (write)
import Test.HTTPure.TestHelpers (Test, getResponseStatus, mockResponse, (?=))
import HTTPurple.Status (write)
import Test.HTTPurple.TestHelpers (Test, getResponseStatus, mockResponse, (?=))
import Test.Spec (describe, it)
writeSpec :: Test

View File

@ -1,4 +1,4 @@
module Test.HTTPure.TestHelpers where
module Test.HTTPurple.TestHelpers where
import Prelude

View File

@ -1,7 +1,7 @@
module Test.HTTPure.UtilsSpec where
module Test.HTTPurple.UtilsSpec where
import HTTPure.Utils (replacePlus)
import Test.HTTPure.TestHelpers (Test, (?=))
import HTTPurple.Utils (replacePlus)
import Test.HTTPurple.TestHelpers (Test, (?=))
import Test.Spec (describe, it)
replacePlusSpec :: Test

View File

@ -1,12 +1,12 @@
module Test.HTTPure.VersionSpec where
module Test.HTTPurple.VersionSpec where
import Prelude
import HTTPure.Version
import HTTPurple.Version
( Version(HTTP0_9, HTTP1_0, HTTP1_1, HTTP2_0, HTTP3_0, Other)
, read
)
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import Test.HTTPurple.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
showSpec :: Test

View File

@ -3,26 +3,26 @@ module Test.Main where
import Prelude
import Effect.Aff (launchAff_)
import Test.HTTPure.BodySpec (bodySpec)
import Test.HTTPure.HeadersSpec (headersSpec)
import Test.HTTPure.IntegrationSpec (integrationSpec)
import Test.HTTPure.LookupSpec (lookupSpec)
import Test.HTTPure.MethodSpec (methodSpec)
import Test.HTTPure.PathSpec (pathSpec)
import Test.HTTPure.QuerySpec (querySpec)
import Test.HTTPure.RequestSpec (requestSpec)
import Test.HTTPure.ResponseSpec (responseSpec)
import Test.HTTPure.ServerSpec (serverSpec)
import Test.HTTPure.StatusSpec (statusSpec)
import Test.HTTPure.TestHelpers (TestSuite)
import Test.HTTPure.UtilsSpec (utilsSpec)
import Test.HTTPure.VersionSpec (versionSpec)
import Test.HTTPurple.BodySpec (bodySpec)
import Test.HTTPurple.HeadersSpec (headersSpec)
import Test.HTTPurple.IntegrationSpec (integrationSpec)
import Test.HTTPurple.LookupSpec (lookupSpec)
import Test.HTTPurple.MethodSpec (methodSpec)
import Test.HTTPurple.PathSpec (pathSpec)
import Test.HTTPurple.QuerySpec (querySpec)
import Test.HTTPurple.RequestSpec (requestSpec)
import Test.HTTPurple.ResponseSpec (responseSpec)
import Test.HTTPurple.ServerSpec (serverSpec)
import Test.HTTPurple.StatusSpec (statusSpec)
import Test.HTTPurple.TestHelpers (TestSuite)
import Test.HTTPurple.UtilsSpec (utilsSpec)
import Test.HTTPurple.VersionSpec (versionSpec)
import Test.Spec (describe)
import Test.Spec.Reporter (specReporter)
import Test.Spec.Runner (runSpec)
main :: TestSuite
main = launchAff_ $ runSpec [ specReporter ] $ describe "HTTPure" do
main = launchAff_ $ runSpec [ specReporter ] $ describe "HTTPurple" do
bodySpec
headersSpec
lookupSpec