diff --git a/build.gradle b/build.gradle index 2a26ac2..71077ce 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' implementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo' + implementation 'org.synchronoss.cloud:nio-multipart-parser:1.1.0' implementation 'org.jetbrains.kotlin:kotlin-reflect' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/src/main/kotlin/risdon/learningspringboot/bootstrap/LoadDatabase.kt b/src/main/kotlin/risdon/learningspringboot/bootstrap/LoadDatabase.kt index 90e0252..887c39d 100644 --- a/src/main/kotlin/risdon/learningspringboot/bootstrap/LoadDatabase.kt +++ b/src/main/kotlin/risdon/learningspringboot/bootstrap/LoadDatabase.kt @@ -11,7 +11,7 @@ import risdon.learningspringboot.repository.ChapterRepository class LoadDatabase { @Bean - fun commandLineRunner(repository: ChapterRepository) = CommandLineRunner{ + fun commandLineRunner(repository: ChapterRepository) = CommandLineRunner { Flux.just( Chapter(name = "Quick Start"), Chapter(name = "Reactive programming"), diff --git a/src/main/kotlin/risdon/learningspringboot/controllers/ImageController.kt b/src/main/kotlin/risdon/learningspringboot/controllers/ImageController.kt new file mode 100644 index 0000000..4eb4c76 --- /dev/null +++ b/src/main/kotlin/risdon/learningspringboot/controllers/ImageController.kt @@ -0,0 +1,30 @@ +package risdon.learningspringboot.controllers + +import org.springframework.web.bind.annotation.* +import reactor.core.publisher.Flux +import reactor.core.publisher.Mono +import risdon.learningspringboot.model.Chapter +import risdon.learningspringboot.model.Image +import risdon.learningspringboot.repository.ChapterRepository + +@RestController +class ImageController () { + + @GetMapping("/images") + fun images(): Flux { + return Flux.just( + Image("1", "Chapter 1.jpg"), + Image("2", "Chapter 2.jpg"), + Image("3", "Chapter 3.jpg") + ) + } + + @PostMapping("/images") + fun create(@RequestBody images: Flux): Mono { + return images.map { + println("We will save $it to a database soon") + it + } + .then() + } +} \ No newline at end of file diff --git a/src/main/kotlin/risdon/learningspringboot/model/Image.kt b/src/main/kotlin/risdon/learningspringboot/model/Image.kt new file mode 100644 index 0000000..3092c42 --- /dev/null +++ b/src/main/kotlin/risdon/learningspringboot/model/Image.kt @@ -0,0 +1,5 @@ +package risdon.learningspringboot.model + +import org.springframework.data.annotation.Id + +data class Image (@Id var id: String? = null, var name: String? = null ) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index ac4084c..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -management.endpoints.web.exposure.include=info,health,metrics,beans diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..4b3d256 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,10 @@ +management: + endpoints: + web: + exposure: + include: info,health,metrics,beans +logging: + level: + io: + netty: DEBUG + reactor: DEBUG \ No newline at end of file