Skip to content

Commit

Permalink
feat: support external types with type widening
Browse files Browse the repository at this point in the history
fixes #1296
  • Loading branch information
worstell committed Jul 9, 2024
1 parent aef7543 commit caa9b59
Show file tree
Hide file tree
Showing 60 changed files with 1,478 additions and 818 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ testdata/**/go.work.sum
# Leaving old _ftl for now to avoid old stuff getting checked in
**/testdata/**/_ftl
**/examples/**/_ftl
**/examples/**/types.ftl.go
**/types.ftl.go
**/testdata/**/.ftl
**/examples/**/.ftl
/.ftl
Expand Down
51 changes: 25 additions & 26 deletions backend/controller/dal/testdata/go/fsm/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions backend/controller/ingress/ingress_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,10 @@ func TestHttpIngress(t *testing.T) {
assert.Equal(t, []string{"application/json; charset=utf-8"}, resp.Headers["Content-Type"])
assert.Equal(t, in.JsonData(t, in.Obj{"name": "A", "value": "hello"}), resp.BodyBytes)
}),
in.HttpCall(http.MethodGet, "/external", in.JsonData(t, in.Obj{"message": "hello"}), func(t testing.TB, resp *in.HTTPResponse) {
assert.Equal(t, 200, resp.Status)
assert.Equal(t, []string{"application/json; charset=utf-8"}, resp.Headers["Content-Type"])
assert.Equal(t, in.JsonData(t, in.Obj{"message": "hello"}), resp.BodyBytes)
}),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"ftl/builtin"

lib "github.com/TBD54566975/ftl/go-runtime/compile/testdata"
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

Expand Down Expand Up @@ -178,3 +179,10 @@ func ArrayData(ctx context.Context, req builtin.HttpRequest[[]ArrayType]) (built
func TypeEnum(ctx context.Context, req builtin.HttpRequest[SumType]) (builtin.HttpResponse[SumType, string], error) {
return builtin.HttpResponse[SumType, string]{Body: ftl.Some(req.Body)}, nil
}

type ExternalAlias lib.NonFTLType

//ftl:ingress http GET /external
func External(ctx context.Context, req builtin.HttpRequest[ExternalAlias]) (builtin.HttpResponse[ExternalAlias, string], error) {
return builtin.HttpResponse[ExternalAlias, string]{Body: ftl.Some(req.Body)}, nil
}
51 changes: 25 additions & 26 deletions backend/controller/leases/testdata/go/leases/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit caa9b59

Please sign in to comment.