git.iko.soy/typeable/bloodhound
on master help sign in
cleanup, making cabal shut the fuck up
3ec86b3Chris Allen
Database/Bloodhound/Client.hs+15−16
@@ -58,16 +58,16 @@ muhServer = "http://localhost:9200"
58
58
59-- bloo <- (liftM responseBody $ parseUrl "http://localhost:9200/" >>= \r -> withManager (httpLbs r))
59-- bloo <- (liftM responseBody $ parseUrl "http://localhost:9200/" >>= \r -> withManager (httpLbs r))
60
60
61−rootPath :: String
61+-- rootPath :: String
62−rootPath = rollUp $ ["/"]
62+-- rootPath = rollUp $ ["/"]
63
63
64−-- Kinda hate this.
64+-- -- Kinda hate this.
65−pathFromType :: String -> String -> String
65+-- pathFromType :: String -> String -> String
66−pathFromType index docType = "/" ++ index ++ docType
66+-- pathFromType index docType = "/" ++ index ++ docType
67
67
68−-- Kinda hate this too.
68+-- -- Kinda hate this too.
69−rollUp :: [String] -> String
69+-- rollUp :: [String] -> String
70−rollUp = Prelude.concat
70+-- rollUp = Prelude.concat
71
71
72main = simpleHttp "http://localhost:9200/events/event/_search?q=hostname:localhost&size=1" >>= L.putStrLn
72main = simpleHttp "http://localhost:9200/events/event/_search?q=hostname:localhost&size=1" >>= L.putStrLn
73
73
@@ -154,28 +154,28 @@ joinPath path = concat $ intersperse "/" path
154
154
155getStatus :: Server -> IO (Maybe (Status Version))
155getStatus :: Server -> IO (Maybe (Status Version))
156getStatus (Server server) = do
156getStatus (Server server) = do
157− request <- parseUrl $ server ++ rootPath
157+ request <- parseUrl $ joinPath [server]
158 response <- withManager $ httpLbs request
158 response <- withManager $ httpLbs request
159 return $ (decode $ responseBody response)
159 return $ (decode $ responseBody response)
160
160
161createIndex :: Server -> IndexSettings -> IndexName -> IO Reply
161createIndex :: Server -> IndexSettings -> IndexName -> IO Reply
162createIndex (Server server) indexSettings indexName =
162createIndex (Server server) indexSettings indexName =
163 dispatch url method body where
163 dispatch url method body where
164− url = server ++ "/" ++ indexName
164+ url = joinPath [server, indexName]
165 method = NHTM.methodPut
165 method = NHTM.methodPut
166 body = Just $ encode indexSettings
166 body = Just $ encode indexSettings
167
167
168deleteIndex :: Server -> IndexName -> IO Reply
168deleteIndex :: Server -> IndexName -> IO Reply
169deleteIndex (Server server) indexName =
169deleteIndex (Server server) indexName =
170 dispatch url method body where
170 dispatch url method body where
171− url = server ++ "/" ++ indexName
171+ url = joinPath [server, indexName]
172 method = NHTM.methodDelete
172 method = NHTM.methodDelete
173 body = Nothing
173 body = Nothing
174
174
175indexExists :: Server -> IndexName -> IO Bool
175indexExists :: Server -> IndexName -> IO Bool
176indexExists (Server server) indexName =
176indexExists (Server server) indexName =
177 exists where
177 exists where
178− url = server ++ "/" ++ indexName
178+ url = joinPath [server, indexName]
179 method = NHTM.methodHead
179 method = NHTM.methodHead
180 body = Nothing
180 body = Nothing
181 reply = dispatch url method body
181 reply = dispatch url method body
@@ -195,7 +195,7 @@ openOrCloseIndexes :: OpenCloseIndex -> Server -> IndexName -> IO Reply
195openOrCloseIndexes oci (Server server) indexName =
195openOrCloseIndexes oci (Server server) indexName =
196 dispatch url method body where
196 dispatch url method body where
197 ociString = stringifyOCIndex oci
197 ociString = stringifyOCIndex oci
198− url = server ++ "/" ++ indexName ++ "/" ++ ociString
198+ url = joinPath [server, indexName, ociString]
199 method = NHTM.methodPost
199 method = NHTM.methodPost
200 body = Nothing
200 body = Nothing
201
201
@@ -211,15 +211,14 @@ createMapping :: ToJSON a => Server -> IndexName
211 -> MappingName -> a -> IO Reply
211 -> MappingName -> a -> IO Reply
212createMapping (Server server) indexName mappingName mapping =
212createMapping (Server server) indexName mappingName mapping =
213 dispatch url method body where
213 dispatch url method body where
214− url = server ++ "/" ++ indexName ++ "/"
215− ++ mappingName ++ "/" ++ "_mapping"
214+ url = joinPath [server, indexName, mappingName, "_mapping"]
216 method = NHTM.methodPut
215 method = NHTM.methodPut
217 body = Just $ encode mapping
216 body = Just $ encode mapping
218
217
219deleteMapping :: Server -> IndexName -> MappingName -> IO Reply
218deleteMapping :: Server -> IndexName -> MappingName -> IO Reply
220deleteMapping (Server server) indexName mappingName =
219deleteMapping (Server server) indexName mappingName =
221 dispatch url method body where
220 dispatch url method body where
222− url = server ++ "/" ++ indexName ++ "/" ++ mappingName ++ "/" ++ "_mapping"
221+ url = joinPath [server, indexName, mappingName, "_mapping"]
223 method = NHTM.methodDelete
222 method = NHTM.methodDelete
224 body = Nothing
223 body = Nothing
225
224
bloodhound.cabal+1
@@ -46,3 +46,4 @@ test-suite tests
46 hspec >= 1.9,
46 hspec >= 1.9,
47 http-conduit,
47 http-conduit,
48 http-types
48 http-types
49+ default-language: Haskell2010