generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow optional values in query params (#1694)
Fixes #1686 Here's the test I used: ```go 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 } ``` ```bash curl -i http://localhost:8891/http/users/123/posts\?postId\=456\&tag\=foo info:echo: Received request with tag: foo ```
- Loading branch information
1 parent
551eb48
commit 871271e
Showing
6 changed files
with
95 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters