File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
src/commonMain/kotlin/com/batchofcode/lambdaruntime Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.batchofcode.lambdaruntime.client
2
2
3
3
import com.batchofcode.lambdaruntime.client.exception.BadRequestException
4
4
import com.batchofcode.lambdaruntime.handler.InvocationRequest
5
+ import com.batchofcode.lambdaruntime.util.containsKey
5
6
import com.batchofcode.lambdaruntime.util.fromMap
6
7
import io.ktor.client.HttpClient
7
8
import io.ktor.client.request.post
@@ -24,14 +25,13 @@ class CommonAwsRuntimeClient(private val client: HttpClient) {
24
25
}
25
26
26
27
suspend fun processRequests (client : HttpClient , handler : (InvocationRequest ) -> String ) {
27
- println (" Requesting invocation from http://${EnvironmentConfiguration .lambdaRuntimeApi} /2018-06-01/runtime/invocation/next" )
28
28
val invocationHttpRequest =
29
29
client.request<HttpResponse >{
30
30
url(" http://${EnvironmentConfiguration .lambdaRuntimeApi} /2018-06-01/runtime/invocation/next" )
31
31
method = HttpMethod .Get
32
32
}
33
33
try {
34
- if (! invocationHttpRequest.headers.contains (" Lambda-Runtime-Aws-Request-Id" )) {
34
+ if (! invocationHttpRequest.headers.containsKey (" Lambda-Runtime-Aws-Request-Id" )) {
35
35
return
36
36
}
37
37
val invocationRequest = RequestMapper .mapRequest(invocationHttpRequest)
Original file line number Diff line number Diff line change 1
1
package com.batchofcode.lambdaruntime.util
2
2
3
+ import io.ktor.http.Headers
3
4
import io.ktor.http.HeadersBuilder
4
5
5
6
fun HeadersBuilder.fromMap (headers : Map <String , String >) {
6
7
this .clear()
7
8
headers.forEach {
8
9
this .append(it.key, it.value)
9
10
}
11
+ }
12
+
13
+ fun Headers.containsKey (key : String ): Boolean {
14
+ return this .entries().any { it.key == key }
10
15
}
You can’t perform that action at this time.
0 commit comments