Skip to content

Commit

Permalink
Update fly implementation in README
Browse files Browse the repository at this point in the history
  • Loading branch information
k-bx committed Jul 30, 2016
1 parent 9fc158f commit 6ef3999
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,19 +513,16 @@ which we will send to our users, plus some logging.
fly :: (Show b, MonadIO m)
=> ExceptT ServantError m b
-> ExceptT ServantErr m b
fly apiReq =
either logAndFail return =<< ExceptT (liftM Right (runExceptT apiReq))
fly apiReq = do
res <- lift (runExceptT apiReq)
either logAndFail return res
where
logAndFail e = do
liftIO (putStrLn ("Got internal-api error: " ++ show e))
throwE internalError
internalError = ServantErr 500 "CyberInternal MicroServer MicroError" "" []
```

I have to admit, it's rather spooky. That's because of a machinery to
convert a `ExceptT e1 m a` into `ExceptT e2 m b`. Maybe there's a
better way, send your PRs!

There you go, now you know how that type-safe microservice-requesting
machinery works. Wasn't that hard, wasn't it!

Expand Down

0 comments on commit 6ef3999

Please sign in to comment.