➕➖ Byttet ut Jackson med KotlinX, la til respons
Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no> Co-authored-by: Markus A. R. Johansen <markus.aleksander.rakil.johansen@nav.no>
This commit is contained in:
		
							parent
							
								
									fdf54063c2
								
							
						
					
					
						commit
						e49bce0470
					
				
					 3 changed files with 9 additions and 12 deletions
				
			
		|  | @ -1,6 +1,9 @@ | |||
| package no.nav.helse.sprik | ||||
| 
 | ||||
| class Test ( | ||||
| import kotlinx.serialization.* | ||||
| 
 | ||||
| @Serializable | ||||
| data class Test ( | ||||
|     var ord: String, | ||||
|     var tall: Int | ||||
| ) { | ||||
|  |  | |||
|  | @ -1,13 +1,11 @@ | |||
| package no.nav.helse.sprik.plugins | ||||
| 
 | ||||
| import com.fasterxml.jackson.databind.SerializationFeature | ||||
| import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | ||||
| import io.ktor.http.* | ||||
| import io.ktor.serialization.jackson.* | ||||
| import io.ktor.server.routing.* | ||||
| import io.ktor.server.response.* | ||||
| import io.ktor.server.application.* | ||||
| import io.ktor.server.plugins.contentnegotiation.* | ||||
| import io.ktor.serialization.kotlinx.json.* | ||||
| import io.ktor.server.plugins.cors.routing.* | ||||
| import io.ktor.server.request.* | ||||
| import no.nav.helse.sprik.Test | ||||
|  | @ -17,14 +15,10 @@ fun Application.configureRouting() { | |||
|         anyHost() | ||||
|         allowMethod(HttpMethod.Get) | ||||
|         allowMethod(HttpMethod.Post) | ||||
|         //allowHeader(HttpHeaders.AccessControlAllowOrigin) | ||||
|         allowNonSimpleContentTypes = true | ||||
|     } | ||||
|     install(ContentNegotiation) { | ||||
|         jackson { | ||||
|             disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) | ||||
|             registerModule(JavaTimeModule()) | ||||
|         } | ||||
|         json() | ||||
|     } | ||||
|     routing { | ||||
|         get("/") { | ||||
|  | @ -33,7 +27,7 @@ fun Application.configureRouting() { | |||
|         post("/test") { | ||||
|             val test = call.receive<Test>() | ||||
|             println(test) | ||||
|             //call.respondText(test.toString()) | ||||
|             call.respond(status = HttpStatusCode.Created, message = test) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Reference in a new issue
	
	 Amalie Mansåker
						Amalie Mansåker