package Ġno . nav . sy fo . util Ċ Ċ import Ġio . ktor . application .* Ċ import Ġio . ktor . http . HttpHeaders . Authorization Ċ import Ġio . ktor . util . pipeline .* Ċ import Ġnet . logstash . log back . argument . Structured Arguments Ċ import Ġjava . time . LocalDateTime Ċ import Ġjava . time . format . DateTime Formatter Ċ import Ġjava . util . concurrent . atomic . Atomic Integer Ċ Ċ const Ġval ĠNAV _ PERSON IDENT _ HEADER Ġ= Ġ" nav - person ident " Ċ Ċ const Ġval ĠTE MA _ HEADER Ġ= Ġ" T ema " Ċ const Ġval ĠAL LE _ TE MA _ HEADER VER DI Ġ= Ġ" GEN " Ċ Ċ const Ġval ĠNAV _ CALL _ ID _ HEADER Ġ= Ġ" Nav - Call - Id " Ċ fun ĠPipeline Context < out ĠUnit , ĠApplication Call >. get Call Id (): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġthis . call . request . headers [ NAV _ CALL _ ID _ HEADER ]. toString () Ċ } Ċ fun Ġcall Id Argument ( call Id : ĠString ) Ġ= ĠStruct ured Arguments . key Value (" call Id ", Ġcall Id ) !! Ċ Ċ const Ġval ĠNAV _ CON SUM ER _ ID _ HEADER Ġ= Ġ" Nav - Consumer - Id " Ċ fun ĠPipeline Context < out ĠUnit , ĠApplication Call >. get Consumer Id (): ĠString Ġ{ ĊĠĠĠ Ġreturn Ġthis . call . request . headers [ NAV _ CON SUM ER _ ID _ HEADER ]. toString () Ċ } Ċ Ċ fun ĠPipeline Context < out ĠUnit , ĠApplication Call >. get Bearer Header (): ĠString ? Ġ{ ĊĠĠĠ Ġreturn Ġthis . call . request . headers [ Authorization ]?. remove Prefix (" Bearer Ġ") Ċ } Ċ Ċ fun ĠPipeline Context < out ĠUnit , ĠApplication Call >. get Person Ident Header (): ĠString ? Ġ{ ĊĠĠĠ Ġreturn Ġthis . call . request . headers [ NAV _ PERSON IDENT _ HEADER ] Ċ } Ċ Ċ private Ġval Ġkafka Counter Ġ= ĠAtomicInteger ( 0 ) Ċ Ċ fun Ġkafka Call Id (): ĠString Ġ= Ġ"${ LocalDateTime . now (). format ( DateTime Formatter . of Pattern (" dd - MM - HH mm ")) }- is nar me ste le der - kafka -${ kafka Counter . increment AndGet () }" Ċ