Skip to content

Commit

Permalink
User Helidon server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Sep 18, 2024
1 parent 2550842 commit 49478cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ following modes:

1. As a Kotlin function with SunHttp dev server for tests - see [app](./app)
1. In a deployed local Undertow server + Apache HTTP client - see [local](./local)
1. To Heroku as a cloud-based Apache server (with Java HTTP client) deployed through a fully CD pipeline run on Travis -
1. To Heroku as a cloud-based Helidon server (with Helidon client) deployed through a fully CD pipeline run on GitHubActions -
see [heroku](./heroku-app)
1. Into a Kubernetes cluster - see [k8s](./k8s)
1. As a pure Kotlin function deployed in a Serverless environment (AWS Lambda) - see [serverless](./serverless)
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ allprojects {

tasks.register("stage") {
dependsOn("installDist")
}

dependencies {
implementation(project(":heroku-app"))
}
5 changes: 3 additions & 2 deletions heroku-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dependencies {
implementation(project(":app"))
implementation("org.http4k:http4k-server-apache")
api(project(":app"))
api("org.http4k:http4k-server-helidon")
api("org.http4k:http4k-client-helidon")
}

application {
Expand Down
8 changes: 4 additions & 4 deletions heroku-app/src/main/kotlin/http4kbox/HerokuServer.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package http4kbox

import org.http4k.client.Java8HttpClient
import org.http4k.client.HelidonClient
import org.http4k.config.Environment
import org.http4k.config.EnvironmentKey
import org.http4k.core.Credentials
import org.http4k.core.then
import org.http4k.filter.ServerFilters.BasicAuth
import org.http4k.server.ApacheServer
import org.http4k.server.Helidon
import org.http4k.server.asServer

// since we are running in a public environment, add credentials to the app
Expand All @@ -18,8 +18,8 @@ fun main(args: Array<String>) {
val port = if (args.isNotEmpty()) args[0].toInt() else 5000

BasicAuth("http4k", BASIC_AUTH_CREDENTIALS(env))
.then(Http4kBox(env, Java8HttpClient()))
.asServer(ApacheServer(port)).start().block()
.then(Http4kBox(env, HelidonClient()))
.asServer(Helidon(port)).start().block()
}

private fun String.toCredentials() = split(":").run { Credentials(get(0), get(1)) }

0 comments on commit 49478cd

Please sign in to comment.