Pypdeveloper
04/29/2020, 7:46 AMImran
04/29/2020, 9:42 AM/static/xyz.json
but I want access it like /static/xyz
using ktor. can anyone know how to do it?AnnoymousGiraf
04/30/2020, 1:20 AMJeremy Rouet
05/01/2020, 2:51 PMJeremy Rouet
05/04/2020, 4:57 PMJeremy Rouet
05/06/2020, 5:00 PMimport io.ktor.application.ApplicationCall
import io.ktor.request.header
import kotlinx.coroutines.asContextElement
const val TENANT_HEADER_VALUE = "tenantID";
const val TENANT_HEADER_URL_VALUE = "tenantURL";
const val CLIENT_HEADER_URL_VALUE = "clientURL";
const val TENANTID_DEFAULT_VALUE = "master"
object ContextManager {
private val context = ThreadLocal<Context>();
/**
* Register a request in the context
*/
fun registerCall(call: ApplicationCall) {
var requestContext = getContext();
var tenantID = call.request.header(TENANT_HEADER_VALUE);
LOGGER.trace("Find ${tenantID} in ${call.request.headers}")
if (tenantID == null || tenantID.isEmpty()) {
tenantID = TENANTID_DEFAULT_VALUE;
}
requestContext.tenantID = tenantID;
requestContext.tenantUrl = call.request.header(TENANT_HEADER_URL_VALUE).toString();
requestContext.clientURL = call.request.header(CLIENT_HEADER_URL_VALUE).toString();
setContext(requestContext);
}
fun setContext(context: Context) {
this.context.set(context);
this.context.asContextElement(context);
}
fun getContext(): Context {
var requestContext = context.get();
if (requestContext == null) {
requestContext = Context()
}
return requestContext;
}
fun declareContext(tenantID: String, tenantUrl: String = "", clientURL: String = "") {
val requestContext = getContext();
requestContext.tenantUrl = tenantUrl;
requestContext.tenantID = tenantID;
requestContext.clientURL = clientURL;
}
}
class Context {
var tenantID = TENANTID_DEFAULT_VALUE;
var tenantUrl = "";
var clientURL = "";
}
Mike Conley
05/09/2020, 1:41 PMException in thread "main" java.lang.IllegalArgumentException: Could not find column mapper for type 'T' of parameter 'parameter #1 value of fun <init>(kotlin.String, T): io.execvision.profile.db.StupidThing<T>' for constructor 'fun <init>(kotlin.String, T): io.execvision.profile.db.StupidThing<T>'
at org.jdbi.v3.core.kotlin.KotlinMapper$resolveConstructorParameterMapper$2.get(KotlinMapper.kt:197)
at org.jdbi.v3.core.kotlin.KotlinMapper$resolveConstructorParameterMapper$2.get(KotlinMapper.kt:51)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.jdbi.v3.core.kotlin.KotlinMapper.resolveConstructorParameterMapper(KotlinMapper.kt:196)
at org.jdbi.v3.core.kotlin.KotlinMapper.specialize0(KotlinMapper.kt:98)
at org.jdbi.v3.core.kotlin.KotlinMapper.specialize(KotlinMapper.kt:73)
at org.jdbi.v3.core.result.ResultSetResultIterator.<init>(ResultSetResultIterator.java:38)
at org.jdbi.v3.core.result.ResultIterable.lambda$of$0(ResultIterable.java:54)
at org.jdbi.v3.core.result.ResultIterable.stream(ResultIterable.java:228)
at org.jdbi.v3.core.result.ResultIterable.collect(ResultIterable.java:284)
at org.jdbi.v3.sqlobject.statement.internal.ResultReturner$CollectedResultReturner.mappedResult(ResultReturner.java:267)
at org.jdbi.v3.sqlobject.statement.internal.SqlQueryHandler.lambda$configureReturner$0(SqlQueryHandler.java:54)
at
...
Kirill Prybylsky
05/10/2020, 11:58 AMwebSocket("/") {
while (true) {
delay(3000)
outgoing.send(Frame.Text("hi"))
}
}
evanchooly
05/13/2020, 5:50 PMzt-exec
. while the built in libs could probably use some help, zt-exec
is really quite nice.Carlos Fau
05/15/2020, 12:06 AMSaša Šijak
05/15/2020, 6:47 AMRyan
05/17/2020, 1:03 PMksinkar
05/19/2020, 6:44 AMxpath
CLI tool to query the XML document in question, but with JAXB XPath. I am not getting the same/expected results with JAXB XPath query analyzer.
Is there an alternative to JAXB in Kotlin?Qverkk
05/23/2020, 1:11 PMSergey Mischenko
05/24/2020, 11:05 AMMgkaki
05/28/2020, 2:38 PMJames Fenn
05/29/2020, 3:08 AMcall.request.uri
and related variables, but it seems that it's getting stripped from the URL. Can't find anything related to this in the documentation (unless I'm looking in entirely the wrong place).
Use case: trying to implement an annoyingly nonstandard OAuth process that ends in a redirect to <http://some.url/#access_token=xxx>
Saša Šijak
05/29/2020, 11:11 AMjaguililla
05/29/2020, 3:13 PMcamkadev
05/30/2020, 12:01 PMcmgurba
06/03/2020, 4:29 PMTableRecordImpl
instead of UpdatableRecordImpl
? thinking it has to do with postgres12 since i recently upgraded...Brian Dilley
06/13/2020, 9:51 PMparth
06/18/2020, 7:46 PMniklas
06/19/2020, 12:52 PMTiago Brito
06/21/2020, 3:35 PMSag333ar
06/24/2020, 3:57 PMembeddedServer(Jetty, 9000) {
install(ContentNegotiation) {
gson {}
}
routing {
post("/account/login") {
// 1. Create URL
val url = URL("<http://some.server.com/account/login>")
// 2. Create HTTP URL Connection
var connection: HttpURLConnection = url.openConnection() as HttpURLConnection
// 3. Add Request Headers
connection.addRequestProperty("Host", "<http://some.server.com|some.server.com>")
connection.addRequestProperty("Content-Type", "application/json;charset=utf-8")
// 4. Set Request method
connection.requestMethod = "POST"
// 5. Set Request Body
val requestBodyText = call.receiveText()
val outputInBytes: ByteArray = requestBodyText.toByteArray(Charsets.UTF_8)
val os: OutputStream = connection.getOutputStream()
os.write(outputInBytes)
os.close()
// 6. Get Response as string from HTTP URL Connection
val string = connection.getInputStream().reader().readText()
// 7. Get headers from HTTP URL Connection
val headerFields = connection.headerFields
// 8. Get Cookies Out of response
val cookiesHeader = headerFields["Set-Cookie"]?.joinToString { "${it};" } ?: ""
// 9. Respond to Client with JSON Data
call.respondText(string, ContentType.Text.JavaScript, HttpStatusCode.OK)
// 10. Add Response headers
call.response.header("Set-Cookie", cookiesHeader)
}
}
}.start(wait = false)
If step 9 is executed first, step 10- doesn't set the headers to response. If step 10 is executed first, step-9 response body isn't set.
How do I send both together - response body & response headers?asad.awadia
06/26/2020, 2:41 PMRohit Singh
06/27/2020, 8:19 AMSlackbot
06/30/2020, 12:17 AMPeter Hsu
07/08/2020, 6:04 PMPeter Hsu
07/08/2020, 6:04 PMFoso
07/08/2020, 6:12 PMPeter Hsu
07/08/2020, 6:18 PMBig Chungus
07/08/2020, 6:50 PMPeter Hsu
07/08/2020, 6:57 PMBig Chungus
07/08/2020, 6:57 PMnapperley
07/09/2020, 12:30 AMESchouten
07/15/2020, 7:49 AMBig Chungus
07/15/2020, 3:53 PM