Skip to content

Commit

Permalink
Opprette kontrakt mellom processor og payload
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Burnett <[email protected]>
Co-authored-by: Alexander Petrov <[email protected]>
  • Loading branch information
alpet and thburnett committed Sep 19, 2023
1 parent fbc8872 commit 86c3a3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
14 changes: 7 additions & 7 deletions payload-processor/src/main/kotlin/no/nav/emottak/App.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.emottak;
package no.nav.emottak

import io.ktor.http.content.PartData
import io.ktor.http.content.forEachPart
Expand All @@ -10,17 +10,18 @@ import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.server.plugins.callloging.CallLogging
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.request.path
import io.ktor.server.request.receiveMultipart
import io.ktor.server.request.*
import io.ktor.server.response.respond
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.post
import io.ktor.server.routing.routing
import kotlinx.serialization.json.Json
import no.nav.emottak.melding.Processor
import no.nav.emottak.melding.model.Header
import no.nav.emottak.melding.model.Melding
import no.nav.emottak.melding.model.Party
import no.nav.emottak.melding.model.PayloadRequest
import org.slf4j.event.Level
import java.util.UUID

Expand Down Expand Up @@ -70,10 +71,9 @@ private fun Application.serverSetup() {
}

post("/payload") {
call.receiveMultipart().forEachPart {
print(it is PartData.BinaryItem)
print(it is PartData.FileItem)
}

val request: PayloadRequest = call.receive(PayloadRequest::class)
println(Json.encodeToString(PayloadRequest.serializer(),request))
call.respondText("Hello")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ data class Melding(
val dekomprimert: Boolean = false
)

@Serializable
data class PayloadRequest(
val header: Header,
val payload: ByteArray
)

@Serializable
data class PayloadResponse(
val processedPayload: ByteArray,
val error: Error? = null
)

@Serializable
data class Error(val message:String)


@Serializable
data class Header(
val messageId: String,
Expand Down

0 comments on commit 86c3a3a

Please sign in to comment.