Skip to content

Instantly share code, notes, and snippets.

@fida1989
Created February 7, 2019 10:52
Show Gist options
  • Save fida1989/b6635aa495eade60de24a496717d6411 to your computer and use it in GitHub Desktop.
Save fida1989/b6635aa495eade60de24a496717d6411 to your computer and use it in GitHub Desktop.
Spring Boot Demo Application
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.*
@SpringBootApplication
@RestController
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
@RestController
class Controller {
@GetMapping("/")
fun helloWorld() = "Hello World"
@GetMapping("/{user}")
fun helloUser(@PathVariable("user") user: String) = "Hello $user!"
@RequestMapping("/")
fun helloUserPost(@RequestParam("user", defaultValue = "User") user: String) = "Hello $user!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment