Updated docs to 0.3 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch gh-pages # Your branch is up-to-date with 'origin/gh-pages'. # # Changes to be committed: # new file: Ketchup-Auth.html # modified: Ketchup-Httpd.html # modified: Ketchup-Routing.html # modified: Ketchup-Utils.html # modified: doc-index.html # modified: index-frames.html # modified: index.html # modified: main.txt # new file: mini_Ketchup-Auth.html # modified: mini_Ketchup-Routing.html # modified: mini_Ketchup-Utils.html # # ------------------------ >8 ------------------------ # Do not touch the line above. # Everything below will be removed. diff --git a/Ketchup-Auth.html b/Ketchup-Auth.html new file mode 100644 index 0000000..ff6a9f5 --- /dev/null +++ b/Ketchup-Auth.html @@ -0,0 +1,8 @@ +Ketchup.Auth

 

Safe HaskellNone

Ketchup.Auth

Synopsis

Documentation

basicAuth

Arguments

∷ [(ByteString, ByteString)]

List of (Username, Password) +

→ ByteString

Authentication Realm +

Handler

Success Handler +

Handler 

Performs HTTP Basic Auth +

\ No newline at end of file diff --git a/Ketchup-Httpd.html b/Ketchup-Httpd.html index b5c49f7..5c7dd67 100644 --- a/Ketchup-Httpd.html +++ b/Ketchup-Httpd.html @@ -1,14 +1,14 @@ Ketchup.Httpd

 

Safe HaskellNone

Ketchup.Httpd

Synopsis

Documentation

data HTTPRequest

HTTP Request type +

Safe HaskellNone

Ketchup.Httpd

Synopsis

Documentation

data HTTPRequest

HTTP Request type This holds a complete HTTP request

Constructors

HTTPRequest 

Fields

method ∷ ByteString

Get HTTP Request Method (GET, POST etc.)

uri ∷ ByteString

Get Request URI

httpver ∷ ByteString

Get HTTP Version

headersHeaders

Get HTTP Headers (header, [values])

body ∷ ByteString

Get HTTP Post body (raw string) -

Instances

type Headers = Map ByteString [ByteString]

type Handler = Socket → HTTPRequest → IO ()

listenHTTP

Arguments

∷ String

Address to bind (ie. *) +

Instances

type Headers = [(ByteString, [ByteString])]

type Handler = Socket → HTTPRequest → IO ()

listenHTTP

Arguments

∷ String

Address to bind (ie. *)

→ PortNumber

Port to listen on

Handler

Route function to call

→ IO () 

Listens for incoming HTTP request diff --git a/Ketchup-Routing.html b/Ketchup-Routing.html index c8298c8..6350f4f 100644 --- a/Ketchup-Routing.html +++ b/Ketchup-Routing.html @@ -1,7 +1,7 @@ Ketchup.Routing

Safe HaskellNone

Ketchup.Routing

Synopsis

Documentation

type Route = Socket → HTTPRequestParameters → IO ()

type Parameters = Map ByteString ByteString

route

Arguments

∷ [(ByteString, Route)]

Routes +

Safe HaskellNone

Ketchup.Routing

Synopsis

Documentation

type Route = Socket → HTTPRequest → (ByteString → Maybe ByteString) → IO ()

route

Arguments

∷ [(ByteString, Route)]

Routes

Handler 

Router function Takes a list of routes and iterates through them for every requeust

useHandlerHandlerRoute

Wrap a handler in a route diff --git a/Ketchup-Utils.html b/Ketchup-Utils.html index d7b0897..0ef0bb4 100644 --- a/Ketchup-Utils.html +++ b/Ketchup-Utils.html @@ -1,9 +1,9 @@ Ketchup.Utils

Safe HaskellNone

Ketchup.Utils

Synopsis

  • trim ∷ ByteString → ByteString
  • breakBS ∷ ByteString → ByteString → (ByteString, ByteString)
  • parseBody ∷ ByteString → Map ByteString ByteString
  • sendReply ∷ Socket → Int → [(ByteString, [ByteString])] → ByteString → IO ()
  • sendBadRequest ∷ Socket → IO ()
  • sendNotFound ∷ Socket → IO ()
  • statusMsg ∷ Int → ByteString

Documentation

trim ∷ ByteString → ByteString

Trim whitespace from headers +

Safe HaskellNone

Ketchup.Utils

Synopsis

  • trim ∷ ByteString → ByteString
  • breakBS ∷ ByteString → ByteString → (ByteString, ByteString)
  • fallback ∷ Maybe a → a → a
  • parseBody ∷ ByteString → [(ByteString, ByteString)]
  • sendReply ∷ Socket → Int → [(ByteString, [ByteString])] → ByteString → IO ()
  • sendBadRequest ∷ Socket → IO ()
  • sendNotFound ∷ Socket → IO ()
  • statusMsg ∷ Int → ByteString

Documentation

trim ∷ ByteString → ByteString

Trim whitespace from headers

breakBS ∷ ByteString → ByteString → (ByteString, ByteString)

ByteString breakSubstring wrapper that drops delimiters -

parseBody ∷ ByteString → Map ByteString ByteString

Parse a URL-encoded Request +

fallback ∷ Maybe a → a → a

parseBody ∷ ByteString → [(ByteString, ByteString)]

Parse a URL-encoded Request

sendReply

Arguments

∷ Socket

Socket to write to

→ Int

Status Code to send

→ [(ByteString, [ByteString])]

HTTP headers (Header,[value1, value2]) diff --git a/doc-index.html b/doc-index.html index ad296ab..e5dc6ab 100644 --- a/doc-index.html +++ b/doc-index.html @@ -1,4 +1,4 @@ (Index)

Index

bodyKetchup.Httpd
breakBSKetchup.Utils
chunkKetchup.Chunked
chunkHeadersKetchup.Chunked
endchunkKetchup.Chunked
HandlerKetchup.Httpd
HeadersKetchup.Httpd
headersKetchup.Httpd
HTTPRequest 
1 (Type/Class)Ketchup.Httpd
2 (Data Constructor)Ketchup.Httpd
httpverKetchup.Httpd
listenHTTPKetchup.Httpd
methodKetchup.Httpd
ParametersKetchup.Routing
parseBodyKetchup.Utils
RouteKetchup.Routing
routeKetchup.Routing
sendBadRequestKetchup.Utils
sendNotFoundKetchup.Utils
sendReplyKetchup.Utils
staticKetchup.Static
statusMsgKetchup.Utils
trimKetchup.Utils
uriKetchup.Httpd
useHandlerKetchup.Routing
\ No newline at end of file +

Index

basicAuthKetchup.Auth
bodyKetchup.Httpd
breakBSKetchup.Utils
chunkKetchup.Chunked
chunkHeadersKetchup.Chunked
endchunkKetchup.Chunked
fallbackKetchup.Utils
HandlerKetchup.Httpd
HeadersKetchup.Httpd
headersKetchup.Httpd
HTTPRequest 
1 (Type/Class)Ketchup.Httpd
2 (Data Constructor)Ketchup.Httpd
httpverKetchup.Httpd
listenHTTPKetchup.Httpd
methodKetchup.Httpd
parseBodyKetchup.Utils
RouteKetchup.Routing
routeKetchup.Routing
sendBadRequestKetchup.Utils
sendNotFoundKetchup.Utils
sendReplyKetchup.Utils
staticKetchup.Static
statusMsgKetchup.Utils
trimKetchup.Utils
uriKetchup.Httpd
useHandlerKetchup.Routing
\ No newline at end of file diff --git a/index-frames.html b/index-frames.html index 9de2c9d..8766065 100644 --- a/index-frames.html +++ b/index-frames.html @@ -1,4 +1,4 @@ \ No newline at end of file + \ No newline at end of file diff --git a/index.html b/index.html index 75be0ea..0427491 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ \ No newline at end of file + \ No newline at end of file diff --git a/main.txt b/main.txt index dab38cf..e8a9b10 100644 --- a/main.txt +++ b/main.txt @@ -10,9 +10,10 @@ trim :: ByteString -> ByteString -- | ByteString breakSubstring wrapper that drops delimiters breakBS :: ByteString -> ByteString -> (ByteString, ByteString) +fallback :: Maybe a -> a -> a -- | Parse a URL-encoded Request -parseBody :: ByteString -> Map ByteString ByteString +parseBody :: ByteString -> [(ByteString, ByteString)] -- | Send a HTTP reply Sends a reply with the given parameters sendReply :: Socket -> Int -> [(ByteString, [ByteString])] -> ByteString -> IO () @@ -46,16 +47,26 @@ headers :: HTTPRequest -> Headers -- | Get HTTP Post body (raw string) body :: HTTPRequest -> ByteString -type Headers = Map ByteString [ByteString] +type Headers = [(ByteString, [ByteString])] type Handler = Socket -> HTTPRequest -> IO () -- | Listens for incoming HTTP request listenHTTP :: String -> PortNumber -> Handler -> IO () instance Show HTTPRequest +module Ketchup.Chunked + +-- | Send HTTP reply headers and begin a Chunked transmission +chunkHeaders :: Socket -> Int -> [(ByteString, [ByteString])] -> IO () + +-- | Sends a chunk +chunk :: Socket -> ByteString -> IO () + +-- | Send the final/closing chunk +endchunk :: Socket -> IO () + module Ketchup.Routing -type Route = Socket -> HTTPRequest -> Parameters -> IO () -type Parameters = Map ByteString ByteString +type Route = Socket -> HTTPRequest -> (ByteString -> Maybe ByteString) -> IO () -- | Router function Takes a list of routes and iterates through them for -- every requeust @@ -70,13 +81,7 @@ module Ketchup.Static -- | Static file handler Takes a directory and returns a route static :: ByteString -> Handler -module Ketchup.Chunked - --- | Send HTTP reply headers and begin a Chunked transmission -chunkHeaders :: Socket -> Int -> [(ByteString, [ByteString])] -> IO () - --- | Sends a chunk -chunk :: Socket -> ByteString -> IO () +module Ketchup.Auth --- | Send the final/closing chunk -endchunk :: Socket -> IO () +-- | Performs HTTP Basic Auth +basicAuth :: [(ByteString, ByteString)] -> ByteString -> Handler -> Handler diff --git a/mini_Ketchup-Auth.html b/mini_Ketchup-Auth.html new file mode 100644 index 0000000..7015cd0 --- /dev/null +++ b/mini_Ketchup-Auth.html @@ -0,0 +1,4 @@ +Ketchup.Auth

Ketchup.Auth

\ No newline at end of file diff --git a/mini_Ketchup-Routing.html b/mini_Ketchup-Routing.html index a33f00a..f8b79cf 100644 --- a/mini_Ketchup-Routing.html +++ b/mini_Ketchup-Routing.html @@ -1,4 +1,4 @@ Ketchup.Routing

Ketchup.Routing

\ No newline at end of file +

Ketchup.Routing

\ No newline at end of file diff --git a/mini_Ketchup-Utils.html b/mini_Ketchup-Utils.html index bfbd19d..cc746e2 100644 --- a/mini_Ketchup-Utils.html +++ b/mini_Ketchup-Utils.html @@ -1,4 +1,4 @@ Ketchup.Utils

Ketchup.Utils

\ No newline at end of file +

Ketchup.Utils

\ No newline at end of file