Skip to content

Commit

Permalink
Merge pull request #80 from kuzzleio/1.3.2-proposal
Browse files Browse the repository at this point in the history
Release 1.3.2
  • Loading branch information
Shiranuit authored Jun 15, 2022
2 parents 8227e58 + 9b6dbca commit 2b40f9b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 30 deletions.
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {

val artifactName = "sdk-jvm"
val artifactGroup = "io.kuzzle"
val artifactVersion = "1.3.1"
val artifactVersion = "1.3.2"

val pomUrl = "https://github.com/kuzzleio/sdk-jvm"
val pomScmUrl = "https://github.com/kuzzleio/sdk-jvm"
Expand All @@ -35,7 +35,7 @@ val pomDeveloperId = "kuzzleio"
val pomDeveloperName = "kuzzle"

group = "io.kuzzle.sdk"
version = "1.3.1"
version = "1.3.2"
val ktorVersion = "1.6.8"

repositories {
Expand All @@ -61,11 +61,11 @@ dependencies {

testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("io.mockk:mockk:1.8.13")
testImplementation("io.ktor:ktor-client-mock:1.3.1")
testImplementation("io.ktor:ktor-client-mock:1.3.2")
testImplementation("io.ktor:ktor-client-mock-jvm:$ktorVersion")
testImplementation("io.ktor:ktor-client-json-jvm:$ktorVersion")
testImplementation("io.ktor:ktor-client-mock-js:1.3.1")
testImplementation("io.ktor:ktor-client-mock-native:1.3.1")
testImplementation("io.ktor:ktor-client-mock-js:1.3.2")
testImplementation("io.ktor:ktor-client-mock-native:1.3.2")
testImplementation("org.mock-server:mockserver-netty:5.3.0")
testImplementation("io.cucumber:cucumber-java8:7.0.0")
testImplementation("io.cucumber:cucumber-junit:7.0.0")
Expand Down
6 changes: 3 additions & 3 deletions doc/1/getting-started/java/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<type>pom</type>
</dependency>
```
Expand All @@ -70,14 +70,14 @@ To build the project, add the following lines:

```groovy
dependencies {
compile 'io.kuzzle:sdk-jvm:1.3.1'
compile 'io.kuzzle:sdk-jvm:1.3.2'
}
```

### Ivy

```html
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.1'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.2'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
6 changes: 3 additions & 3 deletions doc/1/getting-started/kotlin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To build the project, add the following lines:
<dependency>
<groupId>io.kuzzle</groupId>
<artifactId>sdk-jvm</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<type>pom</type>
</dependency>
```
Expand All @@ -82,14 +82,14 @@ To build the project, add the following lines:

```groovy
dependencies {
compile 'io.kuzzle:sdk-jvm:1.3.1'
compile 'io.kuzzle:sdk-jvm:1.3.2'
}
```

### Ivy

```html
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.1'>
<dependency org='io.kuzzle' name='sdk-jvm' rev='1.3.2'>
<artifact name='sdk-jvm' ext='pom' ></artifact>
</dependency>
```
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/io/kuzzle/sdk/Kuzzle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ open class Kuzzle {
return
}

if (! jsonObject.containsKey("headers") && event.headers != null) {
jsonObject = jsonObject.plus("headers" to event.headers)
}

// If the message is empty, we take the requestId of the event,
// to avoid error in fromMap function.
if (! jsonObject.containsKey("requestId") && event.requestId != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package io.kuzzle.sdk.events

data class MessageReceivedEvent(var message: String?, var requestId: String?)
data class MessageReceivedEvent(var message: String?, var requestId: String? = null, var headers: Map<String, List<String>>? = null)
32 changes: 16 additions & 16 deletions src/main/kotlin/io/kuzzle/sdk/protocol/Http.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.ktor.client.call.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.util.*
import io.kuzzle.sdk.coreClasses.exceptions.*
import io.kuzzle.sdk.coreClasses.http.Route
import io.kuzzle.sdk.coreClasses.json.JsonSerializer
Expand Down Expand Up @@ -222,7 +223,7 @@ open class Http : AbstractProtocol {
this.body = JsonSerializer.serialize(payload)
}
// trigger messageReceived
super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?))
super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?, response.headers.toMap()))
} catch (e: Exception) {
super.trigger(RequestErrorEvent(e, payload["requestId"] as String?))
} finally {
Expand Down Expand Up @@ -253,7 +254,7 @@ open class Http : AbstractProtocol {
this.body = if (requestInfo.body != null) JsonSerializer.serialize(requestInfo.body) else ""
}
// trigger messageReceived
super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?))
super.trigger(MessageReceivedEvent(response.receive(), payload["requestId"] as String?, response.headers.toMap()))
} catch (e: Exception) {
super.trigger(RequestErrorEvent(e, payload["requestId"] as String?))
} finally {
Expand Down Expand Up @@ -303,20 +304,19 @@ open class Http : AbstractProtocol {

val route = this.routes["$controller:$action"]

if (route == null) {
super.trigger(RequestErrorEvent(URLNotFoundException(controller, action), payload["requestId"] as String?))
return
}

try {
val requestInfo = route.buildRequest(KuzzleMap.from(payload))
queryHTTPEndpoint(payload, requestInfo)
} catch (e: MissingURLParamException) {
/**
* Fallback if we could not find a matching route with the given parameters
* Try to make the request using directly using /_query endpoint
*/
query(payload)
if (route != null) {
try {
val requestInfo = route.buildRequest(KuzzleMap.from(payload))
queryHTTPEndpoint(payload, requestInfo)
return
} catch (e: MissingURLParamException) {
// Fallback to query
}
}
/**
* Fallback if we could not find a matching route with the given parameters
* Try to make the request using directly using /_query endpoint
*/
query(payload)
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/io/kuzzle/sdk/protocol/WebSocket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ open class WebSocket : AbstractProtocol {
for (frame in incoming) {
when (frame) {
// @TODO Create enums for events
is Frame.Text -> super.trigger(MessageReceivedEvent(frame.readText(), null))
is Frame.Text -> super.trigger(MessageReceivedEvent(frame.readText()))
// @TODO Create enums for events
is Frame.Binary -> super.trigger(MessageReceivedEvent(frame.readBytes().toString(), null))
is Frame.Binary -> super.trigger(MessageReceivedEvent(frame.readBytes().toString()))
is Frame.Close -> TODO()
is Frame.Ping -> TODO()
is Frame.Pong -> TODO()
Expand Down

0 comments on commit 2b40f9b

Please sign in to comment.