Skip to content
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

Multiple handlers with different request and response types #117

Open
stevemao opened this issue Mar 26, 2022 · 0 comments
Open

Multiple handlers with different request and response types #117

stevemao opened this issue Mar 26, 2022 · 0 comments

Comments

@stevemao
Copy link
Contributor

stevemao commented Mar 26, 2022

I can add multiple handlers like this

runLambdaHaskellRuntime
    defaultDispatcherOptions
    (pure ())
    id $ do
      addAPIGatewayHandler "api-gateway" gatewayHandler
      addALBHandler "alb" albHandler
      addStandaloneLambdaHandler "standalone" regularHandler

gatewayHandler ::
  ApiGatewayRequest request ->
  Context context ->
  IO (Either (ApiGatewayResponse error) (ApiGatewayResponse response))
gatewayHandler = doSomething

albHandler ::
  ALBRequest request ->
  Context context ->
  IO (Either (ALBResponse error) (ALBResponse response))
albHandler = doSomething

regularHandler ::
  request ->
  Context context ->
  IO (Either error response)
regularHandler = doSomething

But the request and response type must be the same for all the handlers. What's the recommended way to add handlers with different types?

EG:

gatewayHandler ::
  ApiGatewayRequest Foo ->
  Context context ->
  IO (Either (ApiGatewayResponse Error) (ApiGatewayResponse Bar))
gatewayHandler = doSomething1

albHandler ::
  ALBRequest Bar ->
  Context context ->
  IO (Either (ALBResponse error) (ALBResponse response))
albHandler = doSomething2

regularHandler ::
  request ->
  Context context ->
  IO (Either error response)
regularHandler = doSomething3
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

No branches or pull requests

1 participant