-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for writing Haskell web servers. -- -- A library for writing Haskell web servers. @package http-server @version 1.0.2 module Network.HTTP.Server.HtmlForm -- | An abstraction of a map mapping form fields to their values. data FormFields -- | The names of the fields that were posted. fieldNames :: FormFields -> [String] -- | Do we have the given field? hasField :: FormFields -> String -> Bool -- | Lookup a field value as a string. lookupString :: FormFields -> String -> Maybe String -- | Lookup a field value and try to parse it. lookupRead :: Read a => FormFields -> String -> Maybe a -- | The fields as pairs of strings. toList :: FormFields -> [(String, String)] -- | Try to parse the body of a request. fromRequest :: Request String -> Maybe FormFields instance Show FormFields module Network.HTTP.Server.Logger -- | A type used by the server to report various events. Useful for -- debugging. data Logger Logger :: (Int -> String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> (String -> IO ()) -> (Maybe Int -> (LogType -> Bool) -> IO [LogItem]) -> Logger logInfo :: Logger -> Int -> String -> IO () logDebug :: Logger -> String -> IO () logError :: Logger -> String -> IO () logWarning :: Logger -> String -> IO () getLog :: Logger -> Maybe Int -> (LogType -> Bool) -> IO [LogItem] -- | A logger that uses the standard output and standard error. Text is -- UTF8 encoded. stdLogger :: Logger -- | A logger that does not report anything. quietLogger :: Logger -- | A logger that uses the given handles for output and errors. utf8Logger :: Handle -> Handle -> Logger data LogItem LogItem :: LogType -> String -> LogItem item_type :: LogItem -> LogType item_data :: LogItem -> String data LogType Error :: LogType Warning :: LogType Debug :: LogType Info :: Int -> LogType showLogItem :: LogItem -> String readLogItem :: String -> Maybe LogItem filterLog :: Maybe Int -> (LogType -> Bool) -> [LogItem] -> [LogItem] instance Show LogType module Network.HTTP.Server.Response -- | A list of status code. This not yet complete. data StatusCode OK :: StatusCode SeeOther :: StatusCode BadRequest :: StatusCode Forbidden :: StatusCode NotFound :: StatusCode Found :: StatusCode Conflict :: StatusCode InternalServerError :: StatusCode NotImplemented :: StatusCode -- | Make a simple response with the given status and body. Intended to be -- used for (bad) errors. Adds a close header. err_response :: BufferType a => StatusCode -> Response a -- | Make a simple response with the given status and body. No headers or -- body. respond :: BufferType a => StatusCode -> Response a -- | A brief description of what happend. reason :: StatusCode -> String statusCodeTriplet :: StatusCode -> (Int, Int, Int) module Network.HTTP.Server -- | Start a server with the default configuration, and the given handler. -- Requests are handled in separate threads. server :: HStream a => Handler a -> IO () -- | Start a server with the given configuration and handler. Requests are -- handled in separate threads. serverWith :: HStream a => Config -> Handler a -> IO () -- | Handlers invoked to process requests. The type parameter is for the -- type of the payload in the body. It is a variation on string of some -- sort (e.g., String, ByteString, etc.) type Handler a = SockAddr -> URL -> Request a -> IO (Response a) -- | Server configuration. data Config Config :: Logger -> HostName -> PortNumber -> Config -- | Server reports what's going on here. srvLog :: Config -> Logger -- | Host name to bind to. srvHost :: Config -> HostName -- | Port to listen on. srvPort :: Config -> PortNumber -- | Some default options for a server: no logging output, listen on -- "localhost:8000". defaultConfig :: Config -- | An HTTP Request. The Show instance of this type is used for -- message serialisation, which means no body data is output. data Request a :: * -> * Request :: URI -> RequestMethod -> [Header] -> a -> Request a -- | might need changing in future 1) to support * uri in OPTIONS -- request 2) transparent support for both relative & absolute uris, -- although this should already work (leave scheme & host parts -- empty). rqURI :: Request a -> URI rqMethod :: Request a -> RequestMethod rqHeaders :: Request a -> [Header] rqBody :: Request a -> a -- | An HTTP Response. The Show instance of this type is used for -- message serialisation, which means no body data is output, -- additionally the output will show an HTTP version of 1.1 instead of -- the actual version returned by a server. data Response a :: * -> * Response :: ResponseCode -> String -> [Header] -> a -> Response a rspCode :: Response a -> ResponseCode rspReason :: Response a -> String rspHeaders :: Response a -> [Header] rspBody :: Response a -> a -- | The HTTP request method, to be used in the Request object. We -- are missing a few of the stranger methods, but these are not really -- necessary until we add full TLS. data RequestMethod :: * HEAD :: RequestMethod PUT :: RequestMethod GET :: RequestMethod POST :: RequestMethod DELETE :: RequestMethod OPTIONS :: RequestMethod TRACE :: RequestMethod CONNECT :: RequestMethod Custom :: String -> RequestMethod