Skip to content

Commit dc27426

Browse files
authored
Merge pull request #151 from navikt/ktor3
Oppgrader til ktor 3
2 parents a1e1e53 + 51312f3 commit dc27426

34 files changed

+246
-173
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install ktlint
2222
uses: nbadal/action-ktlint-setup@v1
2323
with:
24-
ktlint_version: '1.0.0'
24+
ktlint_version: '1.3.1'
2525
- name: Ktlint
2626
run: ktlint src/**/*.kt
2727
shell: bash

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ import com.expediagroup.graphql.plugin.gradle.tasks.GraphQLGenerateClientTask
55
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
66
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
77

8-
val ktor_version = "2.3.12"
8+
val ktor_version = "3.0.1"
99
val kotlin_version = "2.0.21"
1010
val kotlinx_datetime_version = "0.6.1"
11-
val kompendium_version = "3.14.4"
11+
val kompendium_version = "4.0.1"
1212
val logback_version = "1.5.12"
1313
val logstash_version = "8.0"
1414
val prometeus_version = "1.6.3"
1515
val nav_common_version = "3.2024.10.25_13.44-9db48a0dbe67"
1616
val tjenestespec_version = "1.2021.02.22-10.45-4201aaea72fb"
17-
val modia_common_utils_version = "1.2023.07.20-13.43-64707e48b53b"
17+
val modia_common_utils_version = "1.2024.10.30-08.17-f565fe211cd4"
1818
val junit_version = "5.11.3"
1919
val graphql_kotlin_version = "8.2.1"
2020

2121
plugins {
2222
application
2323
kotlin("jvm") version "2.0.21"
2424
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.21"
25-
id("com.github.johnrengelman.shadow") version "8.1.1"
25+
id("com.gradleup.shadow") version "8.3.4"
2626
id("com.expediagroup.graphql") version "8.2.1"
2727
}
2828

src/main/kotlin/no/nav/Consumers.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ interface Consumers {
2929
val sfClient: SFClient
3030
}
3131

32-
class ConsumersImpl(env: Env) : Consumers {
32+
class ConsumersImpl(
33+
env: Env,
34+
) : Consumers {
3335
override val oboTokenClient: OnBehalfOfTokenClient =
3436
AzureAdTokenClientBuilder
3537
.builder()

src/main/kotlin/no/nav/Services.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ interface Services {
2020
val utbetalingerService: UtbetalingerService
2121
}
2222

23-
class ServicesImpl(consumers: Consumers) : Services {
23+
class ServicesImpl(
24+
consumers: Consumers,
25+
) : Services {
2426
override val oppfolgingService =
2527
OppfolgingService(
2628
consumers.oppfolgingClient,

src/main/kotlin/no/nav/api/debug/DebugRoutes.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package no.nav.api.debug
22

33
import io.bkbn.kompendium.core.metadata.PostInfo
44
import io.bkbn.kompendium.core.plugin.NotarizedRoute
5+
import io.bkbn.kompendium.oas.payload.MediaType
56
import io.ktor.http.*
67
import io.ktor.server.application.*
78
import io.ktor.server.request.*
@@ -62,10 +63,12 @@ private object Api {
6263
examples(
6364
Pair(
6465
"example",
65-
TokenExchangeRequest(
66-
cluster = "dev-fss",
67-
namespace = "teamname",
68-
application = "app-api",
66+
MediaType.Example(
67+
TokenExchangeRequest(
68+
cluster = "dev-fss",
69+
namespace = "teamname",
70+
application = "app-api",
71+
),
6972
),
7073
),
7174
)

src/main/kotlin/no/nav/api/dialog/saf/SafClient.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class SafClient(
2727
suspend fun hentBrukersSaker(
2828
fnr: String,
2929
token: String,
30-
): GraphQLClientResponse<HentBrukerssaker.Result> {
31-
return externalServiceCall {
30+
): GraphQLClientResponse<HentBrukerssaker.Result> =
31+
externalServiceCall {
3232
graphqlClient.execute(
3333
request =
3434
HentBrukerssaker(
@@ -46,5 +46,4 @@ class SafClient(
4646
},
4747
)
4848
}
49-
}
5049
}

src/main/kotlin/no/nav/api/dialog/saf/SafService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ class SafService(
88
suspend fun hentBrukersSaker(
99
fnr: String,
1010
token: String,
11-
): List<Sak> {
12-
return safClient
11+
): List<Sak> =
12+
safClient
1313
.hentBrukersSaker(fnr, token)
1414
.data
1515
?.saker
1616
?.filterNotNull()
1717
?: emptyList()
18-
}
1918
}

src/main/kotlin/no/nav/api/dialog/sf/SFClient.kt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ class SFClient(
2828
}
2929

3030
@Serializable
31-
data class HenvendelseDTO(val kjedeId: String)
31+
data class HenvendelseDTO(
32+
val kjedeId: String,
33+
)
3234

3335
suspend fun sendSporsmal(
3436
request: SfMeldingRequest,
3537
ident: String,
3638
token: String,
3739
): HenvendelseDTO =
3840
externalServiceCall {
39-
client.post("$sfUrl/henvendelse/ny/melding") {
40-
headers {
41-
append("Nav-Ident", ident)
42-
}
43-
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
44-
contentType(ContentType.Application.Json)
45-
setBody(request)
46-
}.body()
41+
client
42+
.post("$sfUrl/henvendelse/ny/melding") {
43+
headers {
44+
append("Nav-Ident", ident)
45+
}
46+
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
47+
contentType(ContentType.Application.Json)
48+
setBody(request)
49+
}.body()
4750
}
4851

4952
suspend fun sendInfomelding(
@@ -52,14 +55,15 @@ class SFClient(
5255
token: String,
5356
): HenvendelseDTO =
5457
externalServiceCall {
55-
client.post("$sfUrl/henvendelse/ny/melding") {
56-
headers {
57-
append("Nav-Ident", ident)
58-
}
59-
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
60-
contentType(ContentType.Application.Json)
61-
setBody(request)
62-
}.body()
58+
client
59+
.post("$sfUrl/henvendelse/ny/melding") {
60+
headers {
61+
append("Nav-Ident", ident)
62+
}
63+
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
64+
contentType(ContentType.Application.Json)
65+
setBody(request)
66+
}.body()
6367
}
6468

6569
suspend fun journalforMelding(

src/main/kotlin/no/nav/api/dialog/sf/TemagruppeTemaMapping.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ object TemagruppeTemaMapping {
5454
"HJE" to Temagruppe.HJLPM.name,
5555
)
5656

57-
fun hentTemagruppeForTema(tema: String): String {
58-
return if (TEMA_TEMAGRUPPE_MAPPING[tema] == null) TEMA_UTEN_TEMAGRUPPE.name else TEMA_TEMAGRUPPE_MAPPING[tema]!!
59-
}
57+
fun hentTemagruppeForTema(tema: String): String =
58+
if (TEMA_TEMAGRUPPE_MAPPING[tema] == null) TEMA_UTEN_TEMAGRUPPE.name else TEMA_TEMAGRUPPE_MAPPING[tema]!!
6059
}

src/main/kotlin/no/nav/api/digdir/DigdirClient.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@ class DigdirClient(
4848
token: String,
4949
): KrrData =
5050
externalServiceCall {
51-
client.get("$digdirKrrProxyUrl/rest/v1/person") {
52-
headers {
53-
append("Nav-Personident", fnr)
54-
append("Nav-Call-Id", getCallId())
55-
}
56-
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
57-
}.body()
51+
client
52+
.get("$digdirKrrProxyUrl/rest/v1/person") {
53+
headers {
54+
append("Nav-Personident", fnr)
55+
append("Nav-Call-Id", getCallId())
56+
}
57+
header("Authorization", "Bearer ${oboTokenProvider.exchangeOnBehalfOfToken(token)}")
58+
}.body()
5859
}
5960

6061
suspend fun ping() =
6162
externalServiceCall {
62-
client.get("$digdirKrrProxyUrl/rest/ping") {
63-
header("Authorization", "Bearer ${tokenclient.createMachineToMachineToken()}")
64-
}.status
63+
client
64+
.get("$digdirKrrProxyUrl/rest/ping") {
65+
header("Authorization", "Bearer ${tokenclient.createMachineToMachineToken()}")
66+
}.status
6567
}
6668
}

0 commit comments

Comments
 (0)