It's just a project like a toy, it's not very well implementation.
A Simple Web Framework written in kotlin
val simpleContext: SimpleContext = SimpleContext.simpleContext()
val simpleRouter = SimpleRouter.build()
simpleRouter.get("/ping") { ctx ->
ctx.end()
}
simpleContext
.createHttpServer()
.route(simpleRouter)
.listen("127.0.0.1", 8080)
.start()
class ExamplePageController : BaseController {
private val greetingService: ExampleService = ExampleServiceImpl()
override fun register(router: SimpleRouter) {
router.get("/getCalender", ::getCalender)
}
private fun getCalender(ctx: HttpGetContext) {
val resultMap = HashMap<String, Any>()
val dateTime = greetingService.getCalender()
ctx.getHeader("")
resultMap["time"] = dateTime
ctx.end(resultMap)
}
}
interface ExampleService {
fun getCalender(): String
}
class ExampleServiceImpl : ExampleService {
private val exampleMapper = ExampleMapper()
override fun getCalender(): String {
return exampleMapper.timeString
}
}
class ExampleMapper {
// Mock Mapper
var timeString: String = Calendar.getInstance().toString()
}