Scala + Spring Boot (Actuator RESTful API)


build.sbt

import sbt.internal.IvyConsole.Dependencies._

lazy val springVersion = "1.5.3.RELEASE"
lazy val thymeleafVersion = "2.1.5.RELEASE"

lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "org.bk",
scalaVersion := "2.11.0",
version := "1.0"
)),
name := "immosis-scheduler-immobilienscout24",
libraryDependencies += "org.springframework.boot" % "spring-boot-starter-web" % springVersion,
libraryDependencies += "org.springframework.boot" % "spring-boot-starter-actuator" % springVersion
)
mainClass in (Compile, run) := Some("HelloWorldApplication")

HelloWorldApplication.scala

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

object HelloWorldApplication extends App {
SpringApplication.run(classOf[HelloWorldApplication]);
}

@SpringBootApplication
class HelloWorldApplication

HelloWorldController.scala

import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.{GetMapping, RequestParam, ResponseBody}

@Controller
class HelloWorldController {

@GetMapping(Array("/hello-world"))
@ResponseBody
def sayHello(@RequestParam(name="name", required=false, defaultValue="Stranger") name: String): Greeting = {
new Greeting("Hello, "+name)
}
}

Greeting.scala
class Greeting(content: String){
def getContent():String = content
}

sbt run

curl localhost:8080/hello-world
{"content":"Hello, Stranger"}

Advertisements

VCode Debug Mocha


{
"version": "0.2.0",
"configurations": [

{
"name": "Run Mocha",
"request": "launch",
"type": "node",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": ["--opts", "${workspaceFolder}/mocha.opts"],
"cwd": "${workspaceFolder}",
"runtimeExecutable": null,
"env": { },

}
]
}

mocha.opts :

--timeout 60000
--exit
--recursive test
--debug-brk