Skip to content

Instantly share code, notes, and snippets.

@sshine

sshine/Search.hs Secret

Created September 23, 2021 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshine/fd27702785b50f401e088134dc77ca61 to your computer and use it in GitHub Desktop.
Save sshine/fd27702785b50f401e088134dc77ca61 to your computer and use it in GitHub Desktop.
-- curl -v -u "$CVR_USER:$CVR_PASS" -H "Content-Type: application/json" -XPOST "$URL" -d"$QUERY"
searchReq :: SearchQuery -> IO ()
searchReq searchQuery = do
cvrUser <- Env.getEnv "CVR_USER"
cvrPass <- Env.getEnv "CVR_PASS"
runReq tmpHttpConfig $ do
let payload = toJSON searchQuery
r <- req POST (https "distribution.virk.dk" /: "/cvr-permanent/virksomhed/_search")
(ReqBodyJson payload)
bsResponse -- jsonResponse
(basicAuth (BS.pack cvrUser) (BS.pack cvrPass))
-- liftIO $ print (responseBody r :: Value)
liftIO $ print (responseBody r :: ByteString)
where
tmpHttpConfig = defaultHttpConfig
{ httpConfigRetryPolicy = tmpRetryPolicy
}
tmpRetryPolicy :: (Monad m) => RetryPolicyM m
tmpRetryPolicy = Retry.constantDelay 50 <> Retry.limitRetries 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment