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

fix: allow optional values in query params #1694

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

wesbillman
Copy link
Collaborator

Fixes #1686

Here's the test I used:

type GetRequest struct {
	UserID string             `json:"userId"`
	PostID string             `json:"postId"`
	Tag    ftl.Option[string] `json:"tag"`
}

type GetResponse struct {
}

// Example:       curl -i http://localhost:8891/http/users/123/posts?postId=456&tag=foo
//
//ftl:ingress http GET /http/users/{userId}/posts
func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[GetResponse, string], error) {
	tag := req.Body.Tag.Default("No value")
	ftl.LoggerFromContext(ctx).Infof("Received request with tag: %s", tag)
	return builtin.HttpResponse[GetResponse, string]{
		Headers: map[string][]string{"Get": {"Header from FTL"}},
		Body:    ftl.Some(GetResponse{}),
	}, nil
}
curl -i http://localhost:8891/http/users/123/posts\?postId\=456\&tag\=foo

info:echo: Received request with tag: foo

@wesbillman wesbillman requested a review from alecthomas as a code owner June 6, 2024 23:57
@wesbillman wesbillman requested review from a team and worstell and removed request for a team June 6, 2024 23:57
@ftl-robot ftl-robot mentioned this pull request Jun 6, 2024
@wesbillman wesbillman merged commit 871271e into main Jun 7, 2024
37 checks passed
@wesbillman wesbillman deleted the allow-optional-query-params branch June 7, 2024 00:20
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.

HTTP ingress: optional query params don't work
2 participants