Skip to content

Commit

Permalink
feat: support external types with type widening (#2035)
Browse files Browse the repository at this point in the history
unreverts and fixes #2030
  • Loading branch information
worstell authored Jul 10, 2024
1 parent 96890a3 commit 5c5a462
Show file tree
Hide file tree
Showing 60 changed files with 1,469 additions and 819 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 @@ -134,6 +134,11 @@ func TestHttpIngress(t *testing.T) {
assert.Equal(t, nil, resp.Headers["Access-Control-Allow-Methods"])
assert.Equal(t, nil, resp.Headers["Access-Control-Allow-Headers"])
}),
in.HttpCall(http.MethodGet, "/external", nil, 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)
}),
)
}

Expand Down
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 5c5a462

Please sign in to comment.