Skip to content

Commit

Permalink
Merge pull request #5 from itcr-uni-luebeck/gradle-update
Browse files Browse the repository at this point in the history
Gradle update
  • Loading branch information
jpwiedekopf authored Jun 9, 2023
2 parents fa08769 + b26d6b8 commit 335633c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM azul/zulu-openjdk:17
FROM azul/zulu-openjdk-alpine:17
WORKDIR /app
ADD . /app
RUN ./gradlew clean jar
Expand Down
10 changes: 2 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
buildscript {
repositories {
jcenter()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand All @@ -24,14 +20,12 @@ sourceSets {
}

repositories {
mavenLocal()
jcenter()
maven { url 'https://kotlin.bintray.com/ktor' }
mavenCentral()
}

dependencies {
implementation "ch.qos.logback:logback-classic:$logback_version"
implementation 'com.beust:klaxon:5.0.1'
implementation 'com.beust:klaxon:5.6'
implementation "com.natpryce:konfig:1.6.10.0"
implementation "org.jetbrains.kotlinx:kotlinx-cli:0.3.5"
implementation 'io.ktor:ktor-server-content-negotiation-jvm:2.3.1'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import java.io.FileNotFoundException
import java.security.KeyStore
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.*
import javax.net.ssl.SSLContext
import kotlin.io.path.Path
import kotlin.io.path.notExists
Expand Down Expand Up @@ -180,6 +181,8 @@ fun Application.proxyAppModule() {
//we intercept all requests (regardless of routing) at the Call state and pass them to the upstream
intercept(ApplicationCallPipeline.Call) {

val requestId = UUID.randomUUID().toString()

if (this.context.request.httpMethod == HttpMethod.Options) {
mainLogger.info("OPTIONS from ${context.request.origin}")
addCors(call)
Expand All @@ -197,14 +200,18 @@ fun Application.proxyAppModule() {
val requestUri = "$upstreamUri:${configuration[Upstream.port]}/$requestPath".also { mainLogger.info(it) }
//we need to provide a body for POST, PUT, PATCH, but none otherwise

val payloadToUpstreamSize = call.request.headers[HttpHeaders.ContentLength]?.toIntOrNull()?.let {
"$it bytes payload, "
} ?: ""
mainLogger.info(
"${call.request.origin.serverHost}:${call.request.origin.serverPort} " +
"${LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)} " +
"${call.request.httpMethod.value} " +
"\"${call.request.uri}\" " +
"${call.request.headers[HttpHeaders.ContentLength] ?: 0} bytes, " +
payloadToUpstreamSize +
"${call.request.headers[HttpHeaders.ContentType] ?: "-"} " +
"\"${call.request.headers[HttpHeaders.UserAgent]}\""
"\"${call.request.headers[HttpHeaders.UserAgent]}\"" +
"; request-id $requestId"
)

var proxyResponse: HttpResponse
Expand All @@ -230,16 +237,19 @@ fun Application.proxyAppModule() {
}
}
}
mainLogger.debug(
"proxyRequest to {}, {}, status {}",
requestUri,
call.request.httpMethod.value,
proxyResponse.status
)
proxiedHeaders = proxyResponse.headers
location = proxiedHeaders[HttpHeaders.Location]
contentType = proxiedHeaders[HttpHeaders.ContentType]
contentLength = proxiedHeaders[HttpHeaders.ContentLength]
mainLogger.info(
"status {}, method {}, request-uri {}, content-length {} bytes (body-size {}b); request-id {}",
proxyResponse.status.value,
call.request.httpMethod.value,
requestUri,
contentLength,
proxyResponse.bodyAsChannel().toByteArray().size,
requestId
)
}

//check if the status code indicates that the server handled the request correctly. This does not 404s,
Expand Down

0 comments on commit 335633c

Please sign in to comment.