From 880e10b7e6865e9ac6be47db0c2d55399091cc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20C=C3=B3rdoba=20G=C3=B3mez?= Date: Fri, 8 Jan 2021 13:18:06 +0100 Subject: [PATCH] #15 #18 Get Funds --- .../pepe/rest/resteasyjackson/FundResource.kt | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt diff --git a/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt b/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt new file mode 100644 index 000000000..0e982e34b --- /dev/null +++ b/funds/src/main/kotlin/com/pepe/rest/resteasyjackson/FundResource.kt @@ -0,0 +1,58 @@ +package com.pepe.rest.resteasyjackson +import javax.inject.Inject +import javax.enterprise.inject.Default +import javax.enterprise.context.ApplicationScoped +import javax.ws.rs.core.Response.* +import javax.ws.rs.core.Response +import mu.KotlinLogging + + +import java.util.* +import java.time.LocalDateTime + +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.DELETE +import javax.ws.rs.Path +import javax.ws.rs.PathParam +import javax.ws.rs.Produces +import javax.ws.rs.core.MediaType + +private val logger = KotlinLogging.logger {} + +// ./mvnw compile quarkus:dev +@ApplicationScoped +class FundService { + + private val funds = Collections.newSetFromMap(Collections.synchronizedMap(LinkedHashMap())) + + + fun greeting(name: String): String { + return "hello $name" + } + + fun getFunds(): Set{ + return funds + } + + +} + +@Path("/") +class FundResource { + + @Inject + @field: Default + lateinit var service: FundService + + // Get all funds + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/funds") + fun list(): Set { + logger.debug { "GET -> returning funds" } + println("GET -> returning funds") + return service.getFunds() + } + +} \ No newline at end of file