ktor integration - models allowed?
See original GitHub issueHi, trying to use jte with ktor (https://ktor.io/docs/jte.html) however the example and the JteContent
function appears to only accept a map of params, rather than any models or objects.
The example code is
get("/index") {
// ktor example (no model, just a map of params)
val params = mapOf("id" to 1, "name" to "John")
call.respond(JteContent("index.kte", params))
// my attempt, using a model - type mismatch
call.respond(JteContent("test.kte", MyModel(id = 1, name = "John")))
}
// my attempt requires a data class (but fails anyway)
data class MyModel(val id: Int, val name: String)
This would seem to limit compatibility with jte templates that expect models, plus make creating new templates more tedious. Am I missing a way to use models with Ktor and jte or is it limited to Maps/Params? Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
Creating HTTP APIs - Ktor
In this tutorial, we're going to create an HTTP API that can serve as a backend for any application, be it mobile, web,...
Read more >Application structure | Ktor
NET MVC or Ruby on Rails, have the concept of structuring applications using three folders - Model, View, and Controllers (Routes).
Read more >Database persistence with Exposed - Ktor
package com.example.models import org.jetbrains.exposed.sql. ... Ktor allows you to extract such settings to a custom configuration group.
Read more >Creating a cross-platform mobile application - Ktor
In this tutorial, we'll create a simple Kotlin Multiplatform Mobile application, which sends a request and receives a response body as plain HTML...
Read more >Creating an interactive website - Ktor
First, we need to create a model describing an article in our journal application. Create a models package inside com.example , add the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to be clear, this is not a bug or a problem with jte. Just wanted to document the fix in case someone has the same issue and does a search for ClassCastException or something similar.
I just released version 2.1.2 to maven central, including this fix 😃