-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pact-jvm-server): Converted ListServers to kotlin
- Loading branch information
1 parent
22ba232
commit 5cf2e59
Showing
4 changed files
with
18 additions
and
15 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
pact-jvm-server/src/main/kotlin/au/com/dius/pact/server/ListServers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package au.com.dius.pact.server | ||
|
||
import au.com.dius.pact.core.model.OptionalBody | ||
import au.com.dius.pact.core.model.Response | ||
|
||
object ListServers { | ||
private val portRegex = Regex("\\d+") | ||
|
||
@JvmStatic | ||
fun apply(oldState: ServerState): Result { | ||
val ports = oldState.state.keys.filter { it.matches(portRegex) }.joinToString(", ") | ||
val paths = oldState.state.keys.filter { !it.matches(portRegex) }.joinToString(", ") { "\"$it\"" } | ||
val body = OptionalBody.body(("{\"ports\": [$ports], \"paths\": [$paths]}").toByteArray()) | ||
return Result(Response(200, mapOf("Content-Type" to listOf("application/json")).toMutableMap(), body), oldState) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
pact-jvm-server/src/main/scala/au/com/dius/pact/server/Server.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters