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

feat: Add Go helper functions for HttpResponse #2622

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

tomdaffurn
Copy link
Contributor

@tomdaffurn tomdaffurn commented Sep 5, 2024

builtin/external_module.go will have a couple of helper functions added:

// A helper for successful HttpResponse
//
func HttpSuccess[E any, B any](code int, body B) HttpResponse[B, E] {
  return HttpResponse[B, E]{Status: code, Body: ftl.Some(body)}
}

// A helper for HttpResponse with error
//
func HttpError[B any, E any](code int, e E) HttpResponse[B, E] {
  return HttpResponse[B, E]{Status: code, Error: ftl.Some(e)}
}

Fixes: #1632

@tomdaffurn tomdaffurn added the run-all A PR with this label will run the full set of CI jobs in the PR rather than in the merge queue label Sep 5, 2024
@tomdaffurn tomdaffurn marked this pull request as ready for review September 6, 2024 00:24
@tomdaffurn tomdaffurn requested review from a team and stuartwdouglas and removed request for a team September 6, 2024 00:24
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Love it!

@tomdaffurn tomdaffurn added this pull request to the merge queue Sep 6, 2024
Merged via the queue into main with commit a48978d Sep 6, 2024
88 checks passed
@tomdaffurn tomdaffurn deleted the tom/httpresponse-helpers branch September 6, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-all A PR with this label will run the full set of CI jobs in the PR rather than in the merge queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codegen custom helpers for builtins
2 participants