Last active
February 16, 2016 08:34
-
-
Save masahitojp/bae693042214abb9e80c to your computer and use it in GitHub Desktop.
botan handler for Kotlin v1.0.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'kotlin' | |
| apply plugin: 'application' | |
| buildscript { | |
| ext.kotlin_version = '1.0.0' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
| } | |
| } | |
| mainClassName = 'com.github.masahitojp.botan.Botan' | |
| defaultTasks 'run' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | |
| compile 'com.github.masahitojp:botan-core:0.5.0.0' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.github.masahitojp.botan.Botan | |
| import com.github.masahitojp.botan.adapter.ComandLineAdapter | |
| fun main(args: Array<String>) { | |
| Botan.BotanBuilder() | |
| .setAdapter(ComandLineAdapter()) | |
| .build() | |
| .start(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package handlers | |
| import com.github.masahitojp.botan.Robot | |
| import com.github.masahitojp.botan.handler.BotanMessageHandlers | |
| import com.github.masahitojp.botan.message.BotanMessage | |
| class PingHandlers : BotanMessageHandlers { | |
| override fun register(robot: Robot?) { | |
| robot?.respond( | |
| "ping\\z", | |
| "ping method", | |
| {m: BotanMessage -> m.reply("pong")} | |
| ) | |
| robot?.router?.GET("/", {req, res -> "Hello"}) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment