T      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSNone*1configuration to be used with 8 function 3port to listen on 4'maximum amount of POST data (in bytes) 5$maximum file upload size (in bytes) 6%temporary directory for file uploads 7a reasonable default 1 ! ServerConfig { port = 8000 % , ramQuota = 1 * 10^6 & , diskQuota = 20 * 10^6 $ , tmpDir = "/tmp/"  } 88start the server and handle requests using the supplied  9BPop a path element and run the supplied handler if it matches the  given string.   handler :: ServerPart Response . handler = dir "foo" $ dir "bar" $ subHandler !The path element can not contain '/' . See also dirs. :*Pop a path element and parse it using the  fromReqURI in the   class. ;Bguard which only succeeds if there are no remaining path segments 8Often used if you want to explicitly assign a route for T <)Guard using an arbitrary function on the . =!Guard against the request method  Example:  handler :: ServerPart Response  handler =  do method [GET, HEAD]  ... > A low-level function to build a  from a content-type  and a U.  Creates a  in a manner similar to the  class, 0 but without requiring an instance declaration.  example:  # import Data.ByteString.Char8 as C ( import Data.ByteString.Lazy.Char8 as L  import Happstack.Lite  X main = serve Nothing $ ok $ toResponseBS (C.pack "text/plain") (L.pack "hello, world") (note:  and @ only work for ascii. For unicode strings you would need to use  utf8-string, text), or something similar to create a valid U). ? Respond with 200 OK. . main = serve Nothing $ ok "Everything is OK" V Respond with 204 No Content A 204 No Contentb response may not contain a message-body. If you try to supply one, it will be dutifully ignored. : main = serve Nothing $ noContent "This will be ignored." @ Respond with 500 Internal Server Error. Y main = serve Nothing $ internalServerError "Sorry, there was an internal server error." WResponds with 502 Bad Gateway. 2 main = serve Nothing $ badGateway "Bad Gateway." X Respond with 400 Bad Request. 2 main = serve Nothing $ badRequest "Bad Request." A Respond with 401 Unauthorized. ? main = serve Nothing $ unauthorized "You are not authorized." Y Respond with  403 Forbidden. < main = serve Nothing $ forbidden "Sorry, it is forbidden." B Respond with  404 Not Found. P main = serve Nothing $ notFound "What you are looking for has not been found." C/Set an arbitrary return code in your response. AA filter for setting the response code. Generally you will use a  helper function like ? or D. / main = serve Nothing $ do setResponseCode 200 5 return "Everything is OK" Z Respond with 413 Request Entity Too Large. Q main = serve Nothing $ requestEntityTooLarge "That's too big for me to handle." D Respond with  303 See Other.  p main = serve Nothing $ seeOther "http://example.org/" "What you are looking for is now at http://example.org/" NOTE: The second argument of DU is the message body which will sent to the browser. According to the HTTP 1.1 spec,  dthe entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).This is because pre-HTTP/S1.1 user agents do not support 303. However, in practice you can probably just use "" as the second argument. [ Respond with  302 Found. You probably want Dk. This method is not in popular use anymore, and is generally treated like 303 by most user-agents anyway. \ Respond with 301 Moved Permanently. x main = serve Nothing $ movedPermanently "http://example.org/" "What you are looking for is now at http://example.org/" ] Respond with 307 Temporary Redirect. | main = serve Nothing $ tempRedirect "http://example.org/" "What you are looking for is temporarily at http://example.org/" E8Gets the first matching named input parameter as a lazy U 8Searches the QUERY_STRING followed by the Request body.  see also: F F7Gets all matches for the named input parameter as lazy Us 8Searches the QUERY_STRING followed by the Request body.  see also: E G8Gets the first matching named input parameter as a lazy ^ 8Searches the QUERY_STRING followed by the Request body. ?This function assumes the underlying octets are UTF-8 encoded.  see also: H H7Gets all matches for the named input parameter as lazy ^s 8Searches the QUERY_STRING followed by the Request body. ?This function assumes the underlying octets are UTF-8 encoded.  see also: G I#Gets the first matching named file BFiles can only appear in the request body. Additionally, the form  must set enctype=" multipart/ form-data". -This function returns a tuple consisting of:  - The temporary location of the uploaded file , The local filename supplied by the browser * The content-type supplied by the browser DNOTE: You must move the file from the temporary location before the  8 is sent. The temporary files are automatically removed  after the  is sent. J"gets the named cookie as a string K Add the list & to the . L@Expire the named cookie immediately and set the cookie value to ""  main = serve Nothing $  do expireCookie "name" * ok $ "The cookie has been expired." M!Get a header out of the request. N?Add headers into the response. This method does not overwrite 6 any existing header of the same name, hence the name N. % If you want to replace a header use O. O?Set a header into the response. This will replace an existing  header of the same name. Use N if you want to add more # than one header of the same name. PJServe files and directories from a directory and its subdirectories using sendFile. Usage:  F serveDirectory EnableBrowsing ["index.html"] "path/to/files/on/disk" @If the requested path does not match a file or directory on the  disk, then P calls . BIf the requested path is a file then the file is served normally. AIf the requested path is a directory, then the result depends on 3 what the first two arguments to the function are. :The first argument controls whether directory browsing is  enabled. 6The second argument is a list of index files (such as  index.html). When a directory is requested, P will first try to E find one of the index files (in the order they are listed). If that , fails, it will show a directory listing if EnableBrowsing is set,  otherwise it will return  forbidden "Directory index forbidden". ?Here is an explicit list of all the possible outcomes when the " argument is a (valid) directory:  DisableBrowsing, empty index file list #This will always return, forbidden "Directory index forbidden"  DisableBrowsing, non-empty index file list  - If an index file is found it will be shown.  Otherwise returns, forbidden "Directory index forbidden"  EnableBrowsing, empty index file list  Always shows a directory index.  EnableBrowsing, non-empty index file list  , If an index file is found it will be shown # Otherwise shows a directory index  see also: Q QServe a single, specified file. The name of the file being served is specified explicity. It is not derived automatically from the  url.  example 1: "Serve as a specific content-type:  > serveFile (asContentType "image/jpeg") "/srv/data/image.jpg"  example 2: 4Serve guessing the content-type from the extension:  ? serveFile (guessContentTypeM mimeTypes) "/srv/data/image.jpg" QIf the specified path does not exist or is not a file, this function will return . +WARNING: No security checks are performed. NOTE: alias for serveFileUsing filePathSendFile R9returns a specific content type, completely ignoring the _ argument. Use this with Q' if you want to explicitly specify the  content-type.  see also: Q S?try to guess the content-type of a file based on its extension  defaults to application/octet-stream if no match was found. Useful as an argument to Q  see also: Q,  ,12345678if Nothing, then use 7 request handler 9:;<=`> content-type response body ?V@WXAYBCresponse code ZD[\]EFGHI"name of input field to search for <(temporary file location, uploaded file name, content-type) JKLMNOPallow directory browsing <index file names, in case the requested path is a directory file/directory to serve Q9function for determining content-type of file. Typically R path to the file to serve Rthe content-type to return S0map from file extensions to mime-types (usually ) T  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST12345678=9:;< >?@ABDCEFGHI0/.-,&%$#"! +'()*KLJNOM  PQRS'123456789:;<=`>?V@WXAYBCZD[\]EFGHIJKLMNOPQRSa                 ! " # $ % & ' ( ) *+ *, *- *. */ *0 *1 *2 *3 *3 *4 *5 *6 *7 *8 9: 9; 9< 9= 9=>>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrhappstack-lite-7.3.1Happstack.LiteCpackLbase Control.Monad MonadPlusmsummplusmzerohappstack-server-7.3.0Happstack.Server.Routing matchMethod MatchMethod)Happstack.Server.FileServe.BuildingBlocks mimeTypesMimeMapEnableBrowsingDisableBrowsingBrowsingHappstack.Server.Response toResponse toMessage toContentType ToMessage Happstack.Server.Internal.Monads ServerPartHappstack.Server.Internal.TypesGETHEADPOSTPUTDELETETRACEOPTIONSCONNECTMethodResponseRequest fromReqURI FromReqURI Happstack.Server.Internal.CookiemkCookiehttpOnlysecure cookieValue cookieName cookieDomain cookiePath cookieVersionCookieSessionMaxAgeExpiresExpired CookieLife'Happstack.Server.Internal.RFC822Headers ctParameters ctSubtypectType ContentType ServerConfigportramQuota diskQuotatmpDirdefaultServerConfigservedirpathnullDirguardRqmethod toResponseBSokinternalServerError unauthorizednotFoundsetResponseCodeseeOtherlookBSlookBSslookText lookTextslookFilelookCookieValue addCookies expireCookie getHeaderM addHeaderM setHeaderMserveDirectory serveFile asContentTypeguessContentTypeMGHC.Real/bytestring-0.10.0.2Data.ByteString.Lazy.Internal ByteString noContent badGateway badRequest forbiddenrequestEntityTooLargefoundmovedPermanently tempRedirect text-0.11.3.1Data.Text.Lazy.InternalTextGHC.IOFilePath