Skip to content

Commit

Permalink
Add a new hello-world endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthibault79 committed Mar 27, 2024
1 parent b588430 commit a329853
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AppDependenciesBuilder(baselineDependenciesBuilder: BaselineDependenciesBu
as: ActorSystem,
dbReference: DbReference[IO]
): Resource[IO, ServicesDependencies] = {
val helloService = new HelloService()
val statusService = new StatusService(baselineDependencies.samDAO, dbReference)
val diskV2Service = new DiskV2ServiceInterp[IO](
ConfigReader.appConfig.persistentDisk,
Expand Down Expand Up @@ -125,6 +126,7 @@ class AppDependenciesBuilder(baselineDependenciesBuilder: BaselineDependenciesBu
Resource.make[IO, ServicesDependencies](
IO(
ServicesDependencies(
helloService,
statusService,
dependenciesRegistry,
diskV2Service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ object Boot extends IOApp {

val httpRoutes = new HttpRoutes(
servicesDependencies.baselineDependencies.openIDConnectConfiguration,
servicesDependencies.helloService,
servicesDependencies.statusService,
servicesDependencies.cloudSpecificDependenciesRegistry,
servicesDependencies.diskV2Service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ final case class LeoAppDependencies(
* Contains all dependencies for the creation of the HTTP routes (services).
*/
final case class ServicesDependencies(
helloService: HelloService,
statusService: StatusService,
cloudSpecificDependenciesRegistry: ServicesRegistry,
diskV2Service: DiskV2Service[IO],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.broadinstitute.dsde.workbench.leonardo.http.api

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server
import akka.http.scaladsl.server.Directives.{complete, get, pathEndOrSingleSlash, pathPrefix}
import org.broadinstitute.dsde.workbench.leonardo.http.service.HelloService

class HelloRoutes(helloService: HelloService) {
val routes: server.Route =
pathPrefix("hello") {
pathEndOrSingleSlash {
get {
complete(StatusCodes.OK -> helloService.getResponse)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import scala.concurrent.{ExecutionContext, Future}

class HttpRoutes(
oidcConfig: OpenIDConnectConfiguration,
helloService: HelloService,
statusService: StatusService,
gcpOnlyServicesRegistry: ServicesRegistry,
diskV2Service: DiskV2Service[IO],
Expand All @@ -41,6 +42,7 @@ class HttpRoutes(
enableAzureOnlyRoutes: Boolean = false
)(implicit ec: ExecutionContext, ac: ActorSystem, metrics: OpenTelemetryMetrics[IO], logger: StructuredLogger[IO]) {

private val helloRoutes = new HelloRoutes(helloService)
private val statusRoutes = new StatusRoutes(statusService)
private val corsSupport = new CorsSupport(contentSecurityPolicy, refererConfig)
private val kubernetesRoutes = new AppRoutes(kubernetesService, userInfoDirectives)
Expand Down Expand Up @@ -123,7 +125,8 @@ class HttpRoutes(
"swagger/api-docs.yaml"
) ~ oidcConfig.oauth2Routes ~ proxyRoutes.get.route ~ statusRoutes.route ~
pathPrefix("api") {
runtimeRoutes.get.routes ~ runtimeV2Routes.routes ~
helloRoutes.routes ~
runtimeRoutes.get.routes ~ runtimeV2Routes.routes ~
diskRoutes.get.routes ~ kubernetesRoutes.routes ~ appV2Routes.routes ~ diskV2Routes.routes ~ adminRoutes.routes ~
resourcesRoutes.get.routes
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.broadinstitute.dsde.workbench.leonardo.http.service;

import cats.effect.IO

class HelloService {
def getResponse: IO[String] = IO.pure("Hello, World!")
}

0 comments on commit a329853

Please sign in to comment.