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

Add Endpoint serverLogicSuccessPure and serverLogicErrorPure #3837

Merged

Conversation

geirolz
Copy link
Contributor

@geirolz geirolz commented Jun 12, 2024

This PR adds two methods to Endpoint to avoid boilerplates

  • serverLogicSuccessPure - For cases where the result is always a pure success ( healthcheck, stream*, etc... )
  • serverLogicErrorPure - For cases where the result is always a pure failure

* stream = when you build a streamed API the logic is F[Either[E, Stream[...]]] since the errors and the side effects will be handled by the stream you often have to write .serverLogicSuccess(i => myStream(i).pure[F]). with serverLogicSuccessPure you can avoid that small boiler plate when needed.

I also wonder if it would be useful to add something like serverStreamLogic which is equals to serverLogicSuccessPure but have the constraints that the output is a stream ( Idk if this is feasible ). The advantages in this case are just the readability and the clarity of the code

@adamw adamw merged commit f5cdf32 into softwaremill:master Jun 14, 2024
21 checks passed
@adamw
Copy link
Member

adamw commented Jun 14, 2024

Thanks! I think the streaming variatns might be too specialised, as they would also assume that the stream is the only output

@geirolz geirolz deleted the add-endpoint-logic-success-and-error-pure branch June 14, 2024 10:18
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.

2 participants