hack 2009.7.15 → 2009.10.30
raw patch · 5 files changed
+63/−33 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hack: remoteHost :: Env -> String
- Hack: Env :: RequestMethod -> String -> String -> String -> String -> Int -> [(String, String)] -> [Int] -> Hack_UrlScheme -> ByteString -> HackErrors -> [(String, String)] -> [(ByteString, ByteString)] -> Env
+ Hack: Env :: RequestMethod -> String -> String -> String -> String -> Int -> [(String, String)] -> [Int] -> Hack_UrlScheme -> ByteString -> HackErrors -> [(String, String)] -> [(ByteString, ByteString)] -> String -> Env
Files
- LICENSE +27/−5
- changelog.md +14/−0
- hack.cabal +1/−1
- readme.md +18/−26
- src/Hack.hs +3/−1
LICENSE view
@@ -1,9 +1,31 @@ Copyright (c) 2009, Jinjing Wang+ All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:+Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met: -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.-Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.-Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Jinjing Wang nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
changelog.md view
@@ -1,3 +1,17 @@+2009.10.30+----------++### Feature++* add remoteHost field++2009.7.15+---------++### Feature++* new hackCache header using strict bytestrings+ 2009.5.19 ---------
hack.cabal view
@@ -1,5 +1,5 @@ Name: hack-Version: 2009.7.15+Version: 2009.10.30 Build-type: Simple Synopsis: a Haskell Webserver Interface Description:
readme.md view
@@ -1,8 +1,13 @@ Hack: a Haskell Webserver Interface ======================================== -Hack is a brain-dead port of the brilliant Ruby [Rack](http://rack.rubyforge.org/) webserver interface. +Hack is a port of the Ruby's [Rack](http://rack.rubyforge.org/) webserver interface, which itself inspired by Python's [WSGI](http://wsgi.org/wsgi). +Version+-------++> 2009.10.30+ Introduction ------------ @@ -10,9 +15,9 @@ Separation of concerns: -* hack: the spec+* hack: interface spec * hack-middleware: building blocks-* hack-handler: back-ends+* hack-handler: server backends ### Design @@ -40,13 +45,16 @@ * __pathInfo__: The remainder of the request URL‘s “path”, designating the virtual “location” of the request‘s target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This value may be percent-encoded when I originating from a URL. * __queryString__: The portion of the request URL that follows the ?, if any. May be empty, but is always required! * __serverName, serverPort__: When combined with scriptName and pathInfo, these variables can be used to complete the URL. Note, however, that `Host` in http field, if present, should be used in preference to serverName for reconstructing the request URL. serverName and serverPort can never be empty, and so are always required.+* __remoteHost__: The remote host of this request * __http__: Variables corresponding to the client-supplied HTTP request headers (e.g. "Accept"). The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request. * __hackVersion__: The list of `Int`, representing this version of Hack * __hackUrlScheme__: `HTTP` or `HTTPS`, depending on the request URL. * __hackInput__: The body of the request. * __hackErrors__: The error stream. * __hackHeaders__: None http headers, intended to be used by handlers and middleware.+* __hackCache__: High performance cache, could be used by handlers and middleware. + ### The Response * __status__: This is an HTTP status. It must be greater than or equal to 100. @@ -138,37 +146,21 @@ just pass an applied middleware into a chain. -finally the source code of URLMap.hs:+finally the source code of `Config.hs`: - module Hack.Contrib.Middleware.URLMap (url_map) where+ module Hack.Contrib.Middleware.Config (config) where import Hack- import Hack.Contrib.Utils - import MPSUTF8- import Prelude hiding ((.), (^), (>))- import List (find, isPrefixOf)+ config :: (Env -> Env) -> Middleware+ config alter app = \env -> app (alter env) - type RoutePath = (String, Application) - url_map :: [RoutePath] -> Middleware- url_map h app = \env ->- let path = env.path_info- script = env.script_name- mod_env location = env - { scriptName = script ++ location- , pathInfo = path.drop (location.length)- }- in- case h.find (fst > (`isPrefixOf` path) ) of- Nothing -> app env- Just (location, app') -> app' (mod_env location)- ### Use the middleware stack From `Hack.Contrib.Utils`: - -- usage: app.use [content_type, cache]+ -- usage: use [content_type, cache] app use :: [Middleware] -> Middleware use = reduce (<<<) @@ -177,14 +169,14 @@ Once an application is written using Hack, it should work on any web server that provides a Hack handler. -The handler should expose only one function of type:+A handler should expose at least one function of type: run :: Application -> IO () Upgrade ------- -With every new hack release, any library links hack should be recompiled, usually it's simply:+With every new release, any library links to hack should be recompiled against the new version, usually it's simply as: cabal install linked_lib --reinstall
src/Hack.hs view
@@ -42,6 +42,7 @@ , hackErrors :: HackErrors , hackHeaders :: [(String, String)] , hackCache :: [(B.ByteString, B.ByteString)]+ , remoteHost :: String } deriving (Show) @@ -76,7 +77,8 @@ , hackErrors = defaultErrorStream , hackHeaders = def , hackCache = def+ , remoteHost = def } where defaultErrorStream = (hPutStr stderr)- currentVersion = [2009, 7, 15]+ currentVersion = [2009, 10, 30]