Skip to content

Instantly share code, notes, and snippets.

@pengisgood
Last active September 18, 2017 16:41
Show Gist options
  • Save pengisgood/dbea1fcdc45c2bb5809871c7f020b800 to your computer and use it in GitHub Desktop.
Save pengisgood/dbea1fcdc45c2bb5809871c7f020b800 to your computer and use it in GitHub Desktop.
Return customized http status code
buildscript {
ext {
kotlinVersion = '1.1.4-3'
springBootVersion = '2.0.0.M4'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
}
}
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
package me.pengisgood.demo
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
SpringApplication.run(DemoApplication::class.java, *args)
}
package me.pengisgood.demo
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
class DemoController {
@GetMapping("/hello")
fun helloKotlin(): ResponseEntity<Any> {
return ResponseEntity.status(105).build()
}
}
@pengisgood
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment