Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
fix: upgrade to latest FTL (#30)
Browse files Browse the repository at this point in the history
Co-authored-by: Wes <[email protected]>
  • Loading branch information
alecthomas and wesbillman authored Apr 18, 2024
1 parent c796703 commit c62d008
Show file tree
Hide file tree
Showing 44 changed files with 590 additions and 869 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@ jobs:
- name: Test
working-directory: ./online-boutique/web
run: npm run test
backend:
name: Build Backend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Init Hermit
uses: cashapp/activate-hermit@v1
with:
cache: true
- name: Build
run: ftl build --log-level=trace online-boutique
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
44 changes: 0 additions & 44 deletions ftl-examples.code-workspace

This file was deleted.

41 changes: 21 additions & 20 deletions go/http/go.mod
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
module ftl/http

go 1.22.0
go 1.22.2

require github.com/TBD54566975/ftl v0.128.1
require github.com/TBD54566975/ftl v0.180.1

require (
connectrpc.com/connect v1.14.0 // indirect
connectrpc.com/connect v1.16.0 // indirect
connectrpc.com/grpcreflect v1.2.0 // indirect
connectrpc.com/otelconnect v0.7.0 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/TBD54566975/scaffolder v0.8.0 // indirect
github.com/alecthomas/concurrency v0.0.2 // indirect
github.com/alecthomas/kong v0.9.0 // indirect
github.com/alecthomas/participle/v2 v2.1.1 // indirect
github.com/alecthomas/types v0.10.1 // indirect
github.com/alecthomas/types v0.14.0 // indirect
github.com/alessio/shellescape v1.4.2 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.5.3 // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/swaggest/jsonschema-go v0.3.64 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/swaggest/jsonschema-go v0.3.70 // indirect
github.com/swaggest/refl v1.3.0 // indirect
github.com/zalando/go-keyring v0.2.3 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
golang.design/x/reflect v0.0.0-20220504060917-02c43be63f3b // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
github.com/zalando/go-keyring v0.2.4 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
129 changes: 64 additions & 65 deletions go/http/go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions go/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ErrorResponse struct {
// Example: curl -i http://localhost:8892/ingress/http/users/123/posts?postId=456
// Error Example: curl -i http://localhost:8892/ingress/http/users/000/posts?postId=456
//
//ftl:verb
//ftl:export
//ftl:ingress http GET /http/users/{userId}/posts
func Get(ctx context.Context, req builtin.HttpRequest[GetRequest]) (builtin.HttpResponse[GetResponse, ErrorResponse], error) {
if req.Body.UserID == "000" {
Expand Down Expand Up @@ -62,7 +62,7 @@ type PostResponse struct {

// Example: curl -i --json '{"user_id": 123, "post_id": 345}' http://localhost:8892/ingress/http/users
//
//ftl:verb
//ftl:export
//ftl:ingress http POST /http/users
func Post(ctx context.Context, req builtin.HttpRequest[PostRequest]) (builtin.HttpResponse[PostResponse, ftl.Unit], error) {
return builtin.HttpResponse[PostResponse, ftl.Unit]{
Expand All @@ -81,7 +81,7 @@ type PutResponse struct{}

// Example: curl -X PUT http://localhost:8892/ingress/http/users/123 -d '{"postId": "123"}'
//
//ftl:verb
//ftl:export
//ftl:ingress http PUT /http/users/{userId}
func Put(ctx context.Context, req builtin.HttpRequest[PutRequest]) (builtin.HttpResponse[PutResponse, ftl.Unit], error) {
return builtin.HttpResponse[PutResponse, ftl.Unit]{
Expand All @@ -98,7 +98,7 @@ type DeleteResponse struct{}

// Example: curl -X DELETE http://localhost:8892/ingress/http/users/123
//
//ftl:verb
//ftl:export
//ftl:ingress http DELETE /http/users/{userId}
func Delete(ctx context.Context, req builtin.HttpRequest[DeleteRequest]) (builtin.HttpResponse[DeleteResponse, ftl.Unit], error) {
return builtin.HttpResponse[DeleteResponse, ftl.Unit]{
Expand Down
46 changes: 0 additions & 46 deletions kotlin/ftl-module-http/pom.xml

This file was deleted.

File renamed without changes.
78 changes: 25 additions & 53 deletions kotlin/pom.xml → kotlin/http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
<modelVersion>4.0.0</modelVersion>

<groupId>ftl</groupId>
<artifactId>ftl</artifactId>
<artifactId>http</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>pom</packaging>

<modules>
<module>ftl-module-http</module>
</modules>

<properties>
<ftl.version>0.126.0</ftl.version>
<ftlEndpoint>http://127.0.0.1:8892</ftlEndpoint>
<ftl.version>0.180.1</ftl.version>
<java.version>1.8</java.version>
<kotlin.version>1.9.22</kotlin.version>
<kotlin.version>1.9.23</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand All @@ -36,7 +29,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.2</version>
<version>42.7.3</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -77,23 +70,6 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<!-- Install FTL code generator into target directory. -->
<execution>
<phase>initialize</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>xyz.block</groupId>
<artifactId>ftl-generator</artifactId>
<version>${ftl.version}</version>
<destFileName>ftl-generator.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<!-- Copy all dependencies into the target directory -->
<execution>
<id>copy-dependencies</id>
Expand Down Expand Up @@ -131,31 +107,6 @@
</execution>
</executions>
</plugin>
<!-- Run the FTL code generator -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/dependency/ftl-generator.jar</argument>
<argument>--endpoint=${ftlEndpoint}</argument>
<argument>--dest=${project.build.directory}</argument>
<argument>--module=${ftlModuleName}</argument>
<argument>--module-client-suffix=ModuleClient</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- Add sources generated by the FTL tooling -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -183,6 +134,7 @@
<disableDefaultRuleSets>true</disableDefaultRuleSets>
<classPath>${generated.classpath}</classPath>
<jvmTarget>${java.version}</jvmTarget>
<jdkHome>${java.home}</jdkHome>
<config>${project.build.directory}/detekt.yml</config>
<plugins>
<plugin>
Expand All @@ -209,5 +161,25 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<!-- Add generated sources to the classpath -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<!-- Extract schema -->
<plugin>
<groupId>com.github.ozsie</groupId>
<artifactId>detekt-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import xyz.block.ftl.Json
import xyz.block.ftl.Context
import xyz.block.ftl.HttpIngress
import xyz.block.ftl.Method
import xyz.block.ftl.Verb
import xyz.block.ftl.Export

data class GetRequest(
@Json("userId") val userID: String,
Expand Down Expand Up @@ -44,7 +44,7 @@ data class DeleteRequest(

// Example: curl -i http://localhost:8892/ingress/http/users/123/posts?postId=456
// Error Example: curl -i http://localhost:8892/ingress/http/users/000/posts?postId=456
@Verb
@Export
@HttpIngress(Method.GET, "/http/users/{userId}/posts")
fun `get`(context: Context, req: HttpRequest<GetRequest>): HttpResponse<GetResponse, String> {
return HttpResponse(
Expand All @@ -58,7 +58,7 @@ fun `get`(context: Context, req: HttpRequest<GetRequest>): HttpResponse<GetRespo
}

// Example: curl -i --json '{"user_id": 123, "post_id": 345}' http://localhost:8892/ingress/http/users
@Verb
@Export
@HttpIngress(Method.POST, "/http/users")
fun post(context: Context, req: HttpRequest<PostRequest>): HttpResponse<PostResponse, String> {
return HttpResponse(
Expand All @@ -69,7 +69,7 @@ fun post(context: Context, req: HttpRequest<PostRequest>): HttpResponse<PostResp
}

// Example: curl -X PUT http://localhost:8892/ingress/http/users/123 -d '{"postId": "123"}'
@Verb
@Export
@HttpIngress(Method.PUT, "/http/users/{userId}")
fun put(context: Context, req: HttpRequest<PutRequest>): HttpResponse<Empty, String> {
return HttpResponse(
Expand All @@ -80,7 +80,7 @@ fun put(context: Context, req: HttpRequest<PutRequest>): HttpResponse<Empty, Str
}

// Example: curl -X DELETE http://localhost:8892/ingress/http/users/123
@Verb
@Export
@HttpIngress(Method.DELETE, "/http/users/{userId}")
fun delete(context: Context, req: HttpRequest<DeleteRequest>): HttpResponse<Empty, String> {
return HttpResponse(
Expand Down
Loading

0 comments on commit c62d008

Please sign in to comment.