Updated Javalin major version, quick easy refactor of main() as well

This commit is contained in:
Anthony Cicchetti 2019-06-15 14:59:26 -04:00
parent bd826bcf34
commit b1ab0fd65e
4 changed files with 58 additions and 12 deletions

44
.gitattributes vendored Normal file
View file

@ -0,0 +1,44 @@
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.bash text eol=lf
*.css text diff=css
*.df text
*.htm text diff=html
*.html text diff=html
*.java text diff=java
*.kt text
*.js text
*.json text
*.jsp text
*.jspf text
*.jspx text
*.properties text
*.sh text eol=lf
*.tld text
*.txt text
*.tag text
*.tagx text
*.xml text
*.yml text
# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.gif binary
*.ico binary
*.jar binary
*.jpg binary
*.jpeg binary
*.png binary
*.so binary
*.war binary
# Sourced from https://github.com/alexkaratarakis/gitattributes

View file

@ -8,7 +8,7 @@ plugins {
}
group = "com.anthonycicchetti"
version = "0.1.1"
version = "0.1.2"
repositories {
mavenCentral()

View file

@ -13,7 +13,7 @@ object Versions {
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.3.2"
const val javalin: String = "2.8.0" // available: "3.0.0"
const val javalin: String = "3.0.0"
const val org_jetbrains_kotlin_jvm_gradle_plugin: String = "1.3.31"

View file

@ -3,7 +3,7 @@ package com.anthonycicchetti.slackbot
import com.anthonycicchetti.slackbot.utility.Commands
import com.anthonycicchetti.slackbot.utility.RespObj
import com.anthonycicchetti.slackbot.utility.TextResponse
import io.javalin.Context
import io.javalin.http.Context
import io.javalin.Javalin
import org.slf4j.LoggerFactory
@ -11,18 +11,20 @@ fun main() {
val logger = LoggerFactory.getLogger("main")
val app = Javalin.create().start(7000)
app.get("/") { ctx -> ctx.result("Hello World") }
with(app) {
get("/") { ctx -> ctx.result("Hello World") }
app.post("/slack/receive") { ctx ->
handleSlackEvent(ctx)
}
post("/slack/receive") { ctx ->
handleSlackEvent(ctx)
}
app.post("/api/v1/spongebob") { ctx ->
ctx.json(TextResponse(200, ctx.body().toSpongemock()))
}
post("/api/v1/spongebob") { ctx ->
ctx.json(TextResponse(200, ctx.body().toSpongemock()))
}
app.post("/api/v1/uppercase") { ctx ->
ctx.json(TextResponse(200, ctx.body().toUpperCase()))
post("/api/v1/uppercase") { ctx ->
ctx.json(TextResponse(200, ctx.body().toUpperCase()))
}
}
}