stratux-http 0.0.5 → 0.0.6
raw patch · 3 files changed
+69/−10 lines, 3 filesdep +utf8-stringdep ~stratux-typesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: utf8-string
Dependency ranges changed: stratux-types
API changes (from Hackage documentation)
- Data.Aviation.Stratux.HTTP: stratuxHTTP :: HStream b => URIAuth -> String -> String -> String -> IO b
+ Data.Aviation.Stratux.HTTP: getSituation :: URIAuth -> String -> String -> EitherT String IO Situation
+ Data.Aviation.Stratux.HTTP: getSituation' :: URIAuth -> String -> String -> EitherT String IO Situation
+ Data.Aviation.Stratux.HTTP: setSettings :: SettingsSet -> URIAuth -> String -> String -> IO String
Files
- changelog.md +5/−0
- src/Data/Aviation/Stratux/HTTP.hs +61/−8
- stratux-http.cabal +3/−2
changelog.md view
@@ -1,3 +1,8 @@+0.0.6++* add `setSettings` to set the settings.+* add `getSituation` to get the situation.+ 0.0.5 * add `getSettings` to get the settings.
src/Data/Aviation/Stratux/HTTP.hs view
@@ -1,36 +1,43 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+ module Data.Aviation.Stratux.HTTP(- stratuxHTTP-, getWith+ getWith , getStatusWith , getStatus , getStatus' , getSettingsWith , getSettings , getSettings'+, setSettings+, getSituation+, getSituation' ) where import Control.Applicative((<$>)) import Control.Monad((>>=)) import Control.Monad.Trans.Either(EitherT(EitherT))-import Data.Aeson(eitherDecode, eitherDecode')+import Data.Aeson(eitherDecode, eitherDecode', encode) import Data.Aviation.Stratux.Types.Status(Status)-import Data.Aviation.Stratux.Types.Settings(Settings)+import Data.Aviation.Stratux.Types.Settings(Settings, SettingsSet)+import Data.Aviation.Stratux.Types.Situation(Situation)+import qualified Data.ByteString.Lazy.UTF8 as BLU import Data.Either(Either) import Data.Maybe(Maybe(Just)) import Data.String(String)-import Network.HTTP(RequestMethod(GET), simpleHTTP, mkRequest, getResponseBody)+import Network.HTTP(RequestMethod(GET, POST), simpleHTTP, mkRequest, getResponseBody, setRequestBody) import Network.TCP(HStream) import Network.URI(URI(URI), URIAuth) import System.IO(IO) -stratuxHTTP :: +httpGet :: HStream b => URIAuth -- ^ authority @\/\/anonymous\@www.haskell.org:42@ -> String -- ^ @\/ghc@ -> String -- ^ query @?query@ -> String -- ^ fragment @#frag@ -> IO b-stratuxHTTP auth path query fragment =+httpGet auth path query fragment = simpleHTTP (mkRequest GET (URI "http:" (Just auth) path query fragment)) >>= getResponseBody getWith :: @@ -42,7 +49,7 @@ -> String -- ^ fragment @#frag@ -> EitherT e IO a getWith path d auth query fragment =- EitherT (d <$> stratuxHTTP auth path query fragment)+ EitherT (d <$> httpGet auth path query fragment) getStatusWith :: HStream x =>@@ -95,3 +102,49 @@ -> EitherT String IO Settings getSettings' = getSettingsWith eitherDecode'++httpPost ::+ String+ -> String+ -> URIAuth+ -> String+ -> String+ -> String+ -> IO String+httpPost typ body auth path query fragment =+ simpleHTTP (setRequestBody (mkRequest POST (URI "http:" (Just auth) path query fragment)) (typ, body)) >>= getResponseBody++setSettings :: + SettingsSet+ -> URIAuth+ -> String+ -> String+ -> IO String+setSettings s auth =+ httpPost "application/json" (BLU.toString (encode s)) auth "/setSettings"++getSituationWith :: + HStream x =>+ (x -> Either e Situation)+ -> URIAuth -- ^ authority @\/\/anonymous\@www.haskell.org:42@+ -> String -- ^ query @?query@+ -> String -- ^ fragment @#frag@+ -> EitherT e IO Situation+getSituationWith =+ getWith "/getSituation"++getSituation ::+ URIAuth -- ^ authority @\/\/anonymous\@www.haskell.org:42@+ -> String -- ^ query @?query@+ -> String -- ^ fragment @#frag@+ -> EitherT String IO Situation+getSituation =+ getSituationWith eitherDecode++getSituation' ::+ URIAuth -- ^ authority @\/\/anonymous\@www.haskell.org:42@+ -> String -- ^ query @?query@+ -> String -- ^ fragment @#frag@+ -> EitherT String IO Situation+getSituation' =+ getSituationWith eitherDecode'
stratux-http.cabal view
@@ -1,5 +1,5 @@ name: stratux-http-version: 0.0.5+version: 0.0.6 license: BSD3 license-file: LICENCE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>@@ -27,11 +27,12 @@ build-depends: base < 5 && >= 4- , stratux-types >= 0.0.5 && < 0.1+ , stratux-types >= 0.0.6 && < 0.1 , HTTP >= 4000 && < 5000 , network-uri >= 2.6 && < 3.0 , aeson >= 0.11 && < 1.0 , either >= 0.4 && < 5.0+ , utf8-string >= 1.0 && < 2.0 ghc-options: -Wall