Skip to content

Commit

Permalink
No longer use </> to construct REST requests, it'll insert backslashe…
Browse files Browse the repository at this point in the history
…s on Windows
  • Loading branch information
blitzcode committed Mar 20, 2017
1 parent 1b15a40 commit c8e8f6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions HueREST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Control.Monad.IO.Class
import Control.Monad.Catch
import Data.Aeson
import Data.Monoid
import System.FilePath ((</>))
import Network.HTTP.Simple

import Util
Expand Down Expand Up @@ -49,8 +48,8 @@ bridgeRequest :: forall m a body. (MonadIO m, MonadThrow m, FromJSON a, ToJSON b
-> String
-> m a
bridgeRequest method bridgeIP mbBody userID apiEndPoint = do
request' <- parseRequest $ show method <> " http://" <> fromIPAddress bridgeIP </> "api"
</> fromBridgeUserID userID </> apiEndPoint
request' <- parseRequest $ show method <> " http://" <> fromIPAddress bridgeIP <> "/api/"
<> fromBridgeUserID userID <> "/" <> apiEndPoint
let request = case mbBody of
Just j -> setRequestBodyJSON j request'
Nothing -> request'
Expand Down
8 changes: 4 additions & 4 deletions WebUIREST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module WebUIREST ( lightsSetState
, switchAllLights
) where

import Data.Monoid
import Data.Aeson
import Data.Vector ()
import qualified Data.HashMap.Strict as HM
Expand All @@ -21,7 +22,6 @@ import Control.Concurrent.Async
import Control.Lens hiding ((<.>))
import Control.Monad
import Control.Monad.Reader
import System.FilePath

import Util
import PersistConfig
Expand All @@ -48,7 +48,7 @@ lightsSetState bridgeIP userID lightIDs body =
bridgeIP
(Just body)
userID
("lights" </> fromLightID lightID </> "state")
("lights/" <> fromLightID lightID <> "/state")

lightsSetScene :: MonadIO m
=> IPAddress
Expand All @@ -64,7 +64,7 @@ lightsSetScene bridgeIP userID scene =
bridgeIP
(Just lightState)
userID
("lights" </> fromLightID lightID </> "state")
("lights/" <> fromLightID lightID <> "/state")

lightsSwitchOnOff :: MonadIO m => IPAddress -> BridgeUserID -> [LightID] -> Bool -> m ()
lightsSwitchOnOff bridgeIP userID lightIDs onOff =
Expand Down Expand Up @@ -180,5 +180,5 @@ switchAllLights bridgeIP userID onOff =
bridgeIP
(Just body)
userID
("groups" </> "0" </> "action") -- Special group 0, all lights
"groups/0/action" -- Special group 0, all lights

0 comments on commit c8e8f6b

Please sign in to comment.