Copyright | (c) 2016- hiratara |
---|---|
License | BSD-style |
Maintainer | hiratara@cpan.org |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Web.ReqCatcher starts a local HTTP server which handles just one request and returns that request to the client program. It is useful for CLI program to capture HTTP redirects from outer WEB services by using browser.
import Web.Authenticate.OAuth oauth :: OAuth manager :: Manager main :: IO () main = do c <- newCatcher let url = pack (catcherUrl c) oauth' = oauth {oauthCallback = Just url} credential <- getTemporaryCredential oauth' manager putStrLn $ "Access to:\n" ++ (authorizeUrl oauth credential) req <- catchRedirect c let (Just (Just verifier)) = lookup "oauth_verifier" (queryString req) ...
- data Catcher
- newCatcher :: IO Catcher
- newCatcherWithPort :: Port -> IO Catcher
- catchRedirect :: Catcher -> IO Request
Documentation
newCatcher :: IO Catcher Source
Creates the new Catcher instance.
newCatcherWithPort :: Port -> IO Catcher Source
Creates the new Catcher instance with the specific port.
catchRedirect :: Catcher -> IO Request Source
Returns the HTTP request cought by Catcher. This function blocks until Catcher catches some requests.