Last active
March 25, 2019 06:05
-
-
Save dvliman/007f400e82f28ab65d2696fd473e118f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/main/kotlin/com/dvliman/demo/user/UserModels.kt | |
package com.dvliman.demo.user | |
import org.springframework.web.reactive.function.server.ServerResponse | |
import org.springframework.http.MediaType.APPLICATION_JSON | |
import reactor.core.publisher.Mono | |
data class User( | |
val user_id: Int, | |
val name : String, | |
val email : String | |
) | |
data class CreateUserRequest ( | |
val name : String, | |
val email: String | |
) | |
data class FetchUserRequest ( | |
val user_id: Int | |
) | |
typealias CreateUserResponse = FetchUserRequest | |
fun toServerResponse(resp: CreateUserResponse) = ServerResponse | |
.ok() | |
.contentType(APPLICATION_JSON) | |
.body(Mono.just(resp), CreateUserResponse::class.java) | |
fun toServerResponse(user: User) = ServerResponse | |
.ok() | |
.contentType(APPLICATION_JSON) | |
.body(Mono.just(user), User::class.java) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment