Skip to content

Version 4.0.0 - API redesign - no TH + native ALB support #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 1, 2021

Conversation

dnikolovv
Copy link
Contributor

@dnikolovv dnikolovv commented Dec 28, 2020

Since #81 went stale and this is a needed feature, after a discussion with @NickSeagull we decided that I could tackle it.

This is version 4.0.0 - the API is completely redesigned and you no longer need template Haskell. Also, you can write your handler code in any monad.

You can now do this:

initializeConfig :: IO Config
initializeConfig = implementation

main :: IO ()
main = do
  let options = defaultDispatcherOptions

  -- "id" is being used as `m a -> IO a`
  runLambdaHaskellRuntime options initializeConfig id $ do
    addALBHandler "handler" $ \(request :: ALBRequest someRequestType) (context :: IORef Config) ->

  -- or if you want to use API Gateway
  runLambdaHaskellRuntime options initializeConfig id $ do
    addAPIGatewayHandler "handler" $ \(request :: ApiGateway someRequestType) (context :: IORef Config) ->

  -- or if you want to use a standalone lambda
  runLambdaHaskellRuntime options initializeConfig id $ do
    addStandaloneLambdaHandler "handler" $ \(request :: someRequestType) (context :: IORef Config) ->

Using aws-lambda-haskell-runtime-wai, you can now support both API Gateway and ALB like so:

mkApp :: IO Wai.Application
mkApp = implementation

main :: IO ()
main = do
  let options = defaultDispatcherOptions

  runWaiAsLambda
    options
    "handler"
    -- If you want to load-balance multiple lambdas using the same balancer, for each lambda you can
    -- specify the ignored path part so your routes don't break.
    (ignoreALBPathPart "my-lambda")
    mkApp
  • - Bump version to 4.0.0, update to latest stable resolver
  • - Add -Werror and -Wall, clean up
  • - Use ormolu for consistent formatting
  • - Remove TH code
  • - Develop a new "run" API
  • - Enable users to write their handlers in any monad
  • - Update aws-lambda-haskell-runtime-wai
  • - Document

@dnikolovv dnikolovv marked this pull request as draft December 28, 2020 09:55
Copy link
Contributor

@NickSeagull NickSeagull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some comments, will give a more thorough look next year (lol)

Copy link
Contributor

@NickSeagull NickSeagull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I just left some suggestions, let's see if we can get this merged soon.

Thanks a lot 🙏

@NickSeagull
Copy link
Contributor

Hey, what's the status on this?

@freuk
Copy link

freuk commented Feb 25, 2021

This change looks great, I'm using it and am looking forwards to having it in the upcoming release if it gets merged. Thanks.

@dnikolovv
Copy link
Contributor Author

The initial template has been updated and I'm halfway through the docs. Should finish it this Saturday.

@dnikolovv dnikolovv marked this pull request as ready for review February 27, 2021 07:33
@dnikolovv
Copy link
Contributor Author

@NickSeagull The docs are really not perfect (or well done), but I guess we can roll with it and update those at a later stage.

@NickSeagull NickSeagull merged commit 44e58bb into theam:master Mar 1, 2021
@NickSeagull
Copy link
Contributor

Thanks a lot!!!! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants