From 24f87c97773fcb411cc4dfb90f6a3ce927967df0 Mon Sep 17 00:00:00 2001 From: Jan Tennert Date: Sun, 8 Sep 2024 13:40:24 +0000 Subject: [PATCH] Fix custom headers for RPC requests --- .../kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt | 6 ++++-- .../io/github/jan/supabase/postgrest/request/RpcRequest.kt | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt b/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt index c2ca21d4..d997eda4 100644 --- a/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt +++ b/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt @@ -57,7 +57,8 @@ suspend inline fun Postgrest.rpc( count = requestBuilder.count, urlParams = urlParams, body = encodedParameters, - schema = requestBuilder.schema + schema = requestBuilder.schema, + headers = requestBuilder.headers.build() ) return RestRequestExecutor.execute(postgrest = this, path = "rpc/$function", request = rpcRequest) } @@ -78,7 +79,8 @@ suspend inline fun Postgrest.rpc( method = requestBuilder.method.httpMethod, count = requestBuilder.count, urlParams = requestBuilder.params.mapToFirstValue(), - schema = requestBuilder.schema + schema = requestBuilder.schema, + headers = requestBuilder.headers.build() ) return RestRequestExecutor.execute(postgrest = this, path = "rpc/$function", request = rpcRequest) } \ No newline at end of file diff --git a/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/request/RpcRequest.kt b/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/request/RpcRequest.kt index 109d206d..d931213f 100644 --- a/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/request/RpcRequest.kt +++ b/Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/request/RpcRequest.kt @@ -1,7 +1,7 @@ package io.github.jan.supabase.postgrest.request import io.github.jan.supabase.postgrest.query.Count -import io.ktor.http.HttpMethod +import io.ktor.http.* import kotlinx.serialization.json.JsonElement @PublishedApi @@ -10,7 +10,8 @@ internal class RpcRequest( val count: Count? = null, override val urlParams: Map, override val body: JsonElement? = null, - override val schema: String = "public" + override val schema: String = "public", + override val headers: Headers ) : PostgrestRequest { override val prefer = if (count != null) listOf("count=${count.identifier}") else listOf()