From 113e1ebf89575f12b08c81e8ccb7ccc0d7824b77 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Fri, 8 Dec 2023 17:57:26 +0100 Subject: [PATCH 01/36] Add serverless module :wip --- build.gradle.kts | 1 + serverless/serverless_http/README.md | 15 +++++++++++++++ serverless/serverless_http/build.gradle.kts | 16 ++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 33 insertions(+) create mode 100644 serverless/serverless_http/README.md create mode 100644 serverless/serverless_http/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index e5d11fbcac..f21b96e39d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -159,6 +159,7 @@ apiValidation { // Experimental modules "rest", "rest_tools", + "serverless_http", "web", "templates_jte", ) diff --git a/serverless/serverless_http/README.md b/serverless/serverless_http/README.md new file mode 100644 index 0000000000..9d5fab6083 --- /dev/null +++ b/serverless/serverless_http/README.md @@ -0,0 +1,15 @@ + +# Module serverless_http +This port's purpose is to develop HTTP serverless functions. It uses the [http_handlers] module to +process HTTP events. + +[http_handlers]: /http_handlers + +## Install the Dependency +This module is not meant to be used directly. You should include and Adapter implementing this +feature (as [serverless_http_google]) in order to create an HTTP serverless function. + +[serverless_http_google]: /serverless_http_google + +# Package com.hexagonkt.serverless.serverless_http +TODO diff --git a/serverless/serverless_http/build.gradle.kts b/serverless/serverless_http/build.gradle.kts new file mode 100644 index 0000000000..274b2fdf74 --- /dev/null +++ b/serverless/serverless_http/build.gradle.kts @@ -0,0 +1,16 @@ + +plugins { + id("java-library") +} + +apply(from = "$rootDir/gradle/kotlin.gradle") +apply(from = "$rootDir/gradle/publish.gradle") +apply(from = "$rootDir/gradle/dokka.gradle") +apply(from = "$rootDir/gradle/native.gradle") +apply(from = "$rootDir/gradle/detekt.gradle") + +description = "Serverless HTTP functions. Requires an adapter to be used." + +dependencies { + "api"(project(":http:http_handlers")) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 7cad87df8c..94b927da6e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,7 @@ includeNestedModules( "http", "logging", "serialization", + "serverless", "templates" ) From ff8a2dcd564737acf23d0d73e6073197b6d3f1df Mon Sep 17 00:00:00 2001 From: jaguililla Date: Thu, 21 Dec 2023 20:50:02 +0100 Subject: [PATCH 02/36] Set next release version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 38884e4db5..8e5601a4fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.warning.mode=all org.gradle.console=plain # Gradle -version=3.4.6 +version=3.4.7 group=com.hexagonkt description=The atoms of your platform From cec0755004de759a13c63d3c85e1faee2954bc01 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 24 Dec 2023 11:00:52 +0100 Subject: [PATCH 03/36] Update dependencies --- gradle.properties | 2 +- serverless/serverless_http/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 8e5601a4fc..74caab3f24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -37,7 +37,7 @@ mockkVersion=1.13.8 junitVersion=5.10.1 gatlingVersion=3.10.2 jmhVersion=1.37 -mkdocsMaterialVersion=9.5.2 +mkdocsMaterialVersion=9.5.3 mermaidDokkaVersion=0.4.4 nativeToolsVersion=0.9.28 diff --git a/serverless/serverless_http/README.md b/serverless/serverless_http/README.md index 9d5fab6083..6bd2e0d679 100644 --- a/serverless/serverless_http/README.md +++ b/serverless/serverless_http/README.md @@ -11,5 +11,5 @@ feature (as [serverless_http_google]) in order to create an HTTP serverless func [serverless_http_google]: /serverless_http_google -# Package com.hexagonkt.serverless.serverless_http +# Package com.hexagonkt.serverless.serverless.http TODO From 226e9d8a85f4b455e06920ae69c5d9a860f1b6ee Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 24 Dec 2023 12:03:59 +0100 Subject: [PATCH 04/36] Add HTTP controller utility --- http/http_handlers/api/http_handlers.api | 20 ++++++++++++++ .../com/hexagonkt/http/handlers/Handlers.kt | 1 + .../hexagonkt/http/handlers/HttpController.kt | 26 +++++++++++++++++++ .../hexagonkt/http/handlers/HttpHandler.kt | 2 +- .../http/handlers/HttpControllerTest.kt | 22 ++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpController.kt create mode 100644 http/http_handlers/src/test/kotlin/com/hexagonkt/http/handlers/HttpControllerTest.kt diff --git a/http/http_handlers/api/http_handlers.api b/http/http_handlers/api/http_handlers.api index 1b36b35746..c5723780f7 100644 --- a/http/http_handlers/api/http_handlers.api +++ b/http/http_handlers/api/http_handlers.api @@ -279,6 +279,26 @@ public final class com/hexagonkt/http/handlers/HttpContext : com/hexagonkt/handl public synthetic fun with (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Ljava/util/List;ILjava/lang/Exception;Ljava/util/Map;Z)Lcom/hexagonkt/handlers/Context; } +public abstract interface class com/hexagonkt/http/handlers/HttpController : com/hexagonkt/http/handlers/HttpHandler { + public abstract fun addPrefix (Ljava/lang/String;)Lcom/hexagonkt/http/handlers/HttpHandler; + public abstract fun getCallback ()Lkotlin/jvm/functions/Function1; + public abstract fun getHandler ()Lcom/hexagonkt/http/handlers/HttpHandler; + public abstract fun getHandlerPredicate ()Lcom/hexagonkt/http/handlers/HttpPredicate; + public abstract fun getPredicate ()Lkotlin/jvm/functions/Function1; + public abstract fun process (Lcom/hexagonkt/handlers/Context;)Lcom/hexagonkt/handlers/Context; +} + +public final class com/hexagonkt/http/handlers/HttpController$DefaultImpls { + public static fun addPrefix (Lcom/hexagonkt/http/handlers/HttpController;Ljava/lang/String;)Lcom/hexagonkt/http/handlers/HttpHandler; + public static fun byMethod (Lcom/hexagonkt/http/handlers/HttpController;)Ljava/util/Map; + public static fun filter (Lcom/hexagonkt/http/handlers/HttpController;Lcom/hexagonkt/http/model/HttpMethod;)Lcom/hexagonkt/http/handlers/HttpHandler; + public static fun getCallback (Lcom/hexagonkt/http/handlers/HttpController;)Lkotlin/jvm/functions/Function1; + public static fun getHandlerPredicate (Lcom/hexagonkt/http/handlers/HttpController;)Lcom/hexagonkt/http/handlers/HttpPredicate; + public static fun getPredicate (Lcom/hexagonkt/http/handlers/HttpController;)Lkotlin/jvm/functions/Function1; + public static fun process (Lcom/hexagonkt/http/handlers/HttpController;Lcom/hexagonkt/handlers/Context;)Lcom/hexagonkt/handlers/Context; + public static fun process (Lcom/hexagonkt/http/handlers/HttpController;Lcom/hexagonkt/http/model/HttpRequestPort;)Lcom/hexagonkt/http/handlers/HttpContext; +} + public abstract interface class com/hexagonkt/http/handlers/HttpHandler : com/hexagonkt/handlers/Handler { public abstract fun addPrefix (Ljava/lang/String;)Lcom/hexagonkt/http/handlers/HttpHandler; public abstract fun byMethod ()Ljava/util/Map; diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt index 5bdd33f724..a8f67c8c0d 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt @@ -13,6 +13,7 @@ import java.lang.IllegalStateException import java.math.BigInteger import java.security.cert.X509Certificate +// TODO Inline these type aliases and reuse their names in interfaces (better for extension) typealias HttpCallback = HttpContext.() -> HttpContext typealias HttpExceptionCallback = HttpContext.(T) -> HttpContext diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpController.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpController.kt new file mode 100644 index 0000000000..739e813053 --- /dev/null +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpController.kt @@ -0,0 +1,26 @@ +package com.hexagonkt.http.handlers + +import com.hexagonkt.handlers.Context +import com.hexagonkt.http.model.HttpCall + +/** + * Utility to encapsulate a handler in a class. TODO + */ +interface HttpController : HttpHandler { + val handler: HttpHandler + + override val handlerPredicate: HttpPredicate + get() = handler.handlerPredicate + + override fun addPrefix(prefix: String): HttpHandler = + handler.addPrefix(prefix) + + override fun process(context: Context): Context = + handler.process(context) + + override val predicate: (Context) -> Boolean + get() = handler.predicate + + override val callback: (Context) -> Context + get() = handler.callback +} diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpHandler.kt index b9fafda377..8f7dffd0a2 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HttpHandler.kt @@ -37,7 +37,7 @@ sealed interface HttpHandler : Handler { is BeforeHandler -> copy(handlerPredicate = handlerPredicate.clearMethods()) - is ExceptionHandler<*> -> + else -> this } diff --git a/http/http_handlers/src/test/kotlin/com/hexagonkt/http/handlers/HttpControllerTest.kt b/http/http_handlers/src/test/kotlin/com/hexagonkt/http/handlers/HttpControllerTest.kt new file mode 100644 index 0000000000..e343d3d445 --- /dev/null +++ b/http/http_handlers/src/test/kotlin/com/hexagonkt/http/handlers/HttpControllerTest.kt @@ -0,0 +1,22 @@ +package com.hexagonkt.http.handlers + +import com.hexagonkt.http.model.HttpRequest +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +internal class HttpControllerTest { + + class TestController : HttpController { + override val handler: HttpHandler = Get { ok("Good") } + } + + @Test fun `A controller can be used as a handler`() { + + val path = path { + use(TestController()) + } + + val response = path.process(HttpRequest()) + assertEquals("Good", response.response.bodyString()) + } +} From d6d11e8742c08b4348c3a86deccb30aa728afaeb Mon Sep 17 00:00:00 2001 From: jaguililla Date: Tue, 26 Dec 2023 21:13:42 +0100 Subject: [PATCH 05/36] Refactor --- core/src/main/kotlin/com/hexagonkt/core/Jvm.kt | 5 +++-- core/src/main/kotlin/com/hexagonkt/core/text/Cases.kt | 4 ++-- core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt b/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt index 9f3a3711e4..1ba4aeb608 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Jvm.kt @@ -1,5 +1,6 @@ package com.hexagonkt.core +import com.hexagonkt.core.text.SNAKE_CASE import com.hexagonkt.core.text.parseOrNull import java.io.Console import java.net.InetAddress @@ -13,7 +14,7 @@ import kotlin.reflect.KClass * Object with utilities to gather information about the running JVM. */ object Jvm { - private val systemSettingPattern: Regex by lazy { Regex("[a-zA-Z_]+[a-zA-Z0-9_]*") } + private val systemSettingPattern: Regex by lazy { SNAKE_CASE } /** Operating system name ('os.name' property). If `null` throws an exception. */ val os: String by lazy { os() } @@ -149,7 +150,7 @@ object Jvm { private fun systemSettingRaw(name: String): String? { val correctName = name.matches(systemSettingPattern) require(correctName) { "Setting name must match $systemSettingPattern" } - return System.getenv(name) ?: System.getProperty(name) + return System.getenv(name) ?: System.getenv(name.uppercase()) ?: System.getProperty(name) } /** Operating system name ('os.name' property). If `null` throws an exception. */ diff --git a/core/src/main/kotlin/com/hexagonkt/core/text/Cases.kt b/core/src/main/kotlin/com/hexagonkt/core/text/Cases.kt index 673e27728e..7b7af40e2b 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/text/Cases.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/text/Cases.kt @@ -2,8 +2,8 @@ package com.hexagonkt.core.text val CAMEL_CASE: Regex by lazy { Regex("[a-z]+([A-Z][a-z0-9]+)+") } val PASCAL_CASE: Regex by lazy { Regex("([A-Z][a-z0-9]+)+") } -val SNAKE_CASE: Regex by lazy { Regex("[A-Za-z]+(_[A-Za-z0-9]+)+") } -val KEBAB_CASE: Regex by lazy { Regex("[A-Za-z]+(-[A-Za-z0-9]+)+") } +val SNAKE_CASE: Regex by lazy { Regex("[_A-Za-z]+[_A-Za-z0-9]*") } +val KEBAB_CASE: Regex by lazy { Regex("[\\-A-Za-z]+[\\-A-Za-z0-9]*") } fun String.camelToWords(): List = split("(?=\\p{Upper}\\p{Lower})".toRegex()).toWords() diff --git a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt index 42cdae7717..8c03346695 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/JvmTest.kt @@ -41,7 +41,7 @@ internal class JvmTest { assertEquals("z3", System.getProperty("s3")) val e = assertFailsWith { Jvm.loadSystemSettings(mapOf("1" to "v")) } - assertEquals("Property name must match [a-zA-Z_]+[a-zA-Z0-9_]* (1)", e.message) + assertEquals("Property name must match [_A-Za-z]+[_A-Za-z0-9]* (1)", e.message) } @Test fun `OS kind is fetched properly`() { @@ -213,6 +213,7 @@ internal class JvmTest { assert(Jvm.systemSetting("system_property") == "value") assert(Jvm.systemSetting("PATH").isNotEmpty()) + assert(Jvm.systemSetting("path").isNotEmpty()) assertNull(Jvm.systemSettingOrNull("_not_defined_")) System.setProperty("PATH", "path override") From 8d3279521065d1f6c2ca9aeacd922f00e82a76ee Mon Sep 17 00:00:00 2001 From: jaguililla Date: Tue, 26 Dec 2023 21:15:03 +0100 Subject: [PATCH 06/36] Rebrand --- README.md | 8 ++++---- contributing.md | 8 ++++---- http/http_test/src/main/resources/assets/index.html | 10 +++++----- site/mkdocs.yml | 10 +++++----- site/mkdocs/main.html | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 2e37349688..2ef834bdab 100644 --- a/README.md +++ b/README.md @@ -447,8 +447,8 @@ If you like this project and want to support it, the easiest way is to [give it If you feel like you can do more. You can contribute to the project in different ways: -* By using it and [spreading the word][@hexagon_kt]. -* Giving feedback by [Twitter][@hexagon_kt] or [Slack]. +* By using it and [spreading the word][@hexagontk]. +* Giving feedback by [X (Twitter)][@hexagontk] or [Slack]. * Requesting [new features or submitting bugs][issues]. * Voting for the features you want in the [issue tracker][issues] (using [reactions]). * And... Drum roll... Submitting [code or documentation][contributing]. @@ -457,14 +457,14 @@ To know what issues are currently open and be aware of the next features you can [Organization Board] at GitHub. You can ask any question, suggestion or complaint at the project's [Slack channel][Slack]. You can -be up-to-date of project's news following [@hexagon_kt] on Twitter. +be up-to-date of project's news following [@hexagontk] on X (Twitter). Thanks to all project's [contributors]! [![CodeTriage](https://www.codetriage.com/hexagonkt/hexagon/badges/users.svg)][CodeTriage] [give it a star]: https://github.com/hexagonkt/hexagon/stargazers -[@hexagon_kt]: https://twitter.com/hexagon_kt +[@hexagontk]: https://twitter.com/hexagontk [Slack]: https://kotlinlang.slack.com/messages/hexagon [issues]: https://github.com/hexagonkt/hexagon/issues [reactions]: https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments diff --git a/contributing.md b/contributing.md index fc815643ae..cbda36f021 100644 --- a/contributing.md +++ b/contributing.md @@ -7,12 +7,12 @@ process or picking a task and building the code. You can use the repository's [Discussions tab][discussion] to ask questions or resolve problems. You can also ask any question, make suggestions or complaints at the project's -[Slack channel][Slack]. You can also be up-to-date of project's news following [@hexagon_kt] on -Twitter. +[Slack channel][Slack]. You can also be up-to-date of project's news following [@hexagontk] on +X (Twitter). [discussion]: https://github.com/hexagonkt/hexagon/discussions [Slack]: https://kotlinlang.slack.com/messages/hexagon -[@hexagon_kt]: https://twitter.com/hexagon_kt +[@hexagontk]: https://twitter.com/hexagontk ## Report a Bug To file a bug, create an issue with the [bug template]. @@ -120,7 +120,7 @@ If you want to generate the documentation site, check the Hexagon's site module * Dev.to * Kotlin Slack * Reddit Kotlin - * Twitter + * X (Twitter) * Kotlin Weekly Newsletter * LinkedIn * Mailing lists (Awesome Kotlin, Kotlin Weekly) diff --git a/http/http_test/src/main/resources/assets/index.html b/http/http_test/src/main/resources/assets/index.html index 57aa9e563d..b21e834a02 100644 --- a/http/http_test/src/main/resources/assets/index.html +++ b/http/http_test/src/main/resources/assets/index.html @@ -37,8 +37,8 @@ - - + + @@ -107,7 +107,7 @@ @@ -258,7 +258,7 @@

Contribute

Community

@@ -291,7 +291,7 @@

Community

aria-label="Fork hexagonkt/hexagon on GitHub">Fork + href="https://twitter.com/share?text=Hexagon Toolkit">Post diff --git a/site/mkdocs.yml b/site/mkdocs.yml index 935e6dabe9..7535f41da7 100644 --- a/site/mkdocs.yml +++ b/site/mkdocs.yml @@ -71,7 +71,7 @@ nav: - Planning: planning.md - Contributing ↗: https://github.com/hexagonkt/hexagon/contribute - GitHub ↗: https://github.com/hexagonkt - - Dev.to ↗: https://dev.to/hexagonkt + - Dev.to ↗: https://dev.to/hexagontk - LibHunt ↗: https://kotlin.libhunt.com/hexagon-alternatives - StackShare ↗: https://stackshare.io/hexagon @@ -127,14 +127,14 @@ extra: provider: google property: G-BEKWF2E4DJ - twitter_user: hexagon_kt + twitter_user: hexagontk social: - icon: fontawesome/brands/github link: https://github.com/hexagonkt - icon: fontawesome/brands/dev - link: https://dev.to/hexagonkt - - icon: fontawesome/brands/twitter - link: https://twitter.com/hexagon_kt + link: https://dev.to/hexagontk + - icon: fontawesome/brands/x-twitter + link: https://twitter.com/hexagontk - icon: fontawesome/brands/slack link: https://kotlinlang.slack.com/messages/hexagon diff --git a/site/mkdocs/main.html b/site/mkdocs/main.html index 5b41d02be3..6130d174e9 100644 --- a/site/mkdocs/main.html +++ b/site/mkdocs/main.html @@ -128,7 +128,7 @@ aria-label="Fork {{ config.extra.repo }} on GitHub">Fork + href="https://twitter.com/intent/tweet?text=Hexagon Toolkit">Post {{ extracopyright }} From e12b5f03ccf765de2f2ecdbc681a955b8fe38c85 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 1 Jan 2024 18:47:54 +0100 Subject: [PATCH 07/36] Refactor --- .../handlers/ExceptionHandlerTest.kt | 2 +- http/http_handlers/api/http_handlers.api | 6 +++ .../hexagonkt/http/handlers/AfterHandler.kt | 8 +-- .../hexagonkt/http/handlers/BeforeHandler.kt | 8 +-- .../http/handlers/ExceptionHandler.kt | 2 +- .../hexagonkt/http/handlers/FilterHandler.kt | 8 +-- .../hexagonkt/http/handlers/HandlerBuilder.kt | 54 +++++++++---------- .../com/hexagonkt/http/handlers/Handlers.kt | 35 ++++++------ .../com/hexagonkt/http/handlers/OnHandler.kt | 8 +-- .../http/test/examples/ClientTest.kt | 4 +- .../http/test/examples/SamplesTest.kt | 2 +- .../rest/SerializeRequestCallback.kt | 3 +- .../rest/SerializeResponseCallback.kt | 3 +- .../rest/tools/openapi/OpenApiHandler.kt | 4 +- .../rest/tools/openapi/VerifySpecCallback.kt | 3 +- 15 files changed, 80 insertions(+), 70 deletions(-) diff --git a/handlers/src/test/kotlin/com/hexagonkt/handlers/ExceptionHandlerTest.kt b/handlers/src/test/kotlin/com/hexagonkt/handlers/ExceptionHandlerTest.kt index e91eebd254..7738a93ea4 100644 --- a/handlers/src/test/kotlin/com/hexagonkt/handlers/ExceptionHandlerTest.kt +++ b/handlers/src/test/kotlin/com/hexagonkt/handlers/ExceptionHandlerTest.kt @@ -49,7 +49,7 @@ internal class ExceptionHandlerTest { ChainHandler( ExceptionHandler(Exception::class, false) { c, _ -> c.with("ok") }, - ExceptionHandler(Exception::class, false) { c, _ -> error("Fail") }, + ExceptionHandler(Exception::class, false) { _, _ -> error("Fail") }, OnHandler { error("Error") } ) .process(EventContext("test", { true })) diff --git a/http/http_handlers/api/http_handlers.api b/http/http_handlers/api/http_handlers.api index c5723780f7..c8d5c88067 100644 --- a/http/http_handlers/api/http_handlers.api +++ b/http/http_handlers/api/http_handlers.api @@ -193,6 +193,9 @@ public final class com/hexagonkt/http/handlers/HandlersKt { public static synthetic fun process$default (Lkotlin/jvm/functions/Function1;Lcom/hexagonkt/http/model/HttpRequest;Ljava/util/Map;ILjava/lang/Object;)Lcom/hexagonkt/http/handlers/HttpContext; } +public abstract interface class com/hexagonkt/http/handlers/HttpCallback : kotlin/jvm/functions/Function1 { +} + public final class com/hexagonkt/http/handlers/HttpContext : com/hexagonkt/handlers/Context { public fun (Lcom/hexagonkt/handlers/Context;)V public fun (Lcom/hexagonkt/http/model/HttpCall;Lkotlin/jvm/functions/Function1;Ljava/util/List;ILjava/lang/Exception;Ljava/util/Map;Z)V @@ -299,6 +302,9 @@ public final class com/hexagonkt/http/handlers/HttpController$DefaultImpls { public static fun process (Lcom/hexagonkt/http/handlers/HttpController;Lcom/hexagonkt/http/model/HttpRequestPort;)Lcom/hexagonkt/http/handlers/HttpContext; } +public abstract interface class com/hexagonkt/http/handlers/HttpExceptionCallback : kotlin/jvm/functions/Function2 { +} + public abstract interface class com/hexagonkt/http/handlers/HttpHandler : com/hexagonkt/handlers/Handler { public abstract fun addPrefix (Ljava/lang/String;)Lcom/hexagonkt/http/handlers/HttpHandler; public abstract fun byMethod ()Ljava/util/Map; diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/AfterHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/AfterHandler.kt index e59de2bd80..35a6ea0e17 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/AfterHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/AfterHandler.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KClass data class AfterHandler( override val handlerPredicate: HttpPredicate = HttpPredicate(), - val block: HttpCallback + val block: HttpCallbackType ) : HttpHandler, Handler by AfterHandler(handlerPredicate, toCallback(block)) { constructor( @@ -17,14 +17,14 @@ data class AfterHandler( pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - block: HttpCallback, + block: HttpCallbackType, ) : this(HttpPredicate(methods, pattern, exception, status), block) - constructor(method: HttpMethod, pattern: String = "", block: HttpCallback) : + constructor(method: HttpMethod, pattern: String = "", block: HttpCallbackType) : this(setOf(method), pattern, block = block) - constructor(pattern: String, block: HttpCallback) : + constructor(pattern: String, block: HttpCallbackType) : this(emptySet(), pattern, block = block) override fun addPrefix(prefix: String): HttpHandler = diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/BeforeHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/BeforeHandler.kt index 4261a919a8..5f61157291 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/BeforeHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/BeforeHandler.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KClass data class BeforeHandler( override val handlerPredicate: HttpPredicate = HttpPredicate(), - val block: HttpCallback, + val block: HttpCallbackType, ) : HttpHandler, Handler by BeforeHandler(handlerPredicate, toCallback(block)) { constructor( @@ -17,14 +17,14 @@ data class BeforeHandler( pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - block: HttpCallback, + block: HttpCallbackType, ) : this(HttpPredicate(methods, pattern, exception, status), block) - constructor(method: HttpMethod, pattern: String = "", block: HttpCallback) : + constructor(method: HttpMethod, pattern: String = "", block: HttpCallbackType) : this(setOf(method), pattern, block = block) - constructor(pattern: String, block: HttpCallback) : + constructor(pattern: String, block: HttpCallbackType) : this(emptySet(), pattern, block = block) override fun addPrefix(prefix: String): HttpHandler = diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/ExceptionHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/ExceptionHandler.kt index 2c123747e4..4acd949a8a 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/ExceptionHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/ExceptionHandler.kt @@ -8,7 +8,7 @@ import kotlin.reflect.KClass data class ExceptionHandler( val exception: KClass, val clear: Boolean = true, - val block: HttpExceptionCallback + val block: HttpExceptionCallbackType ) : HttpHandler, Handler by ExceptionHandler(exception, clear, toCallback(block)) { override val handlerPredicate: HttpPredicate = HttpPredicate() diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/FilterHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/FilterHandler.kt index c26f2bebfd..7c5feeff5d 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/FilterHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/FilterHandler.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KClass data class FilterHandler( override val handlerPredicate: HttpPredicate = HttpPredicate(), - val block: HttpCallback + val block: HttpCallbackType ) : HttpHandler, Handler by FilterHandler(handlerPredicate, toCallback(block)) { constructor( @@ -17,14 +17,14 @@ data class FilterHandler( pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - block: HttpCallback, + block: HttpCallbackType, ) : this(HttpPredicate(methods, pattern, exception, status), block) - constructor(method: HttpMethod, pattern: String = "", block: HttpCallback) : + constructor(method: HttpMethod, pattern: String = "", block: HttpCallbackType) : this(setOf(method), pattern, block = block) - constructor(pattern: String, block: HttpCallback) : + constructor(pattern: String, block: HttpCallbackType) : this(emptySet(), pattern, block = block) override fun addPrefix(prefix: String): HttpHandler = diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HandlerBuilder.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HandlerBuilder.kt index ee5b5f67b6..cd2d9a14ed 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HandlerBuilder.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/HandlerBuilder.kt @@ -32,7 +32,7 @@ class HandlerBuilder(var handlers: List = emptyList()) { fun on( predicate: HttpPredicate = HttpPredicate(), - callback: HttpCallback + callback: HttpCallbackType ) { use(OnHandler(predicate, callback)) } @@ -42,22 +42,22 @@ class HandlerBuilder(var handlers: List = emptyList()) { pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - callback: HttpCallback, + callback: HttpCallbackType, ) { use(OnHandler(methods, pattern, exception, status, callback)) } - fun on(method: HttpMethod, pattern: String = "", callback: HttpCallback) { + fun on(method: HttpMethod, pattern: String = "", callback: HttpCallbackType) { use(OnHandler(method, pattern, callback)) } - fun on(pattern: String, callback: HttpCallback) { + fun on(pattern: String, callback: HttpCallbackType) { use(OnHandler(pattern, callback)) } fun filter( predicate: HttpPredicate = HttpPredicate(), - callback: HttpCallback + callback: HttpCallbackType ) { use(FilterHandler(predicate, callback)) } @@ -67,24 +67,24 @@ class HandlerBuilder(var handlers: List = emptyList()) { pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - callback: HttpCallback, + callback: HttpCallbackType, ) { use( FilterHandler(methods, pattern, exception, status, callback) ) } - fun filter(method: HttpMethod, pattern: String = "", callback: HttpCallback) { + fun filter(method: HttpMethod, pattern: String = "", callback: HttpCallbackType) { use(FilterHandler(method, pattern, callback)) } - fun filter(pattern: String, callback: HttpCallback) { + fun filter(pattern: String, callback: HttpCallbackType) { use(FilterHandler(pattern, callback)) } fun after( predicate: HttpPredicate = HttpPredicate(), - callback: HttpCallback + callback: HttpCallbackType ) { use(AfterHandler(predicate, callback)) } @@ -94,22 +94,22 @@ class HandlerBuilder(var handlers: List = emptyList()) { pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - callback: HttpCallback, + callback: HttpCallbackType, ) { use(AfterHandler(methods, pattern, exception, status, callback)) } - fun after(method: HttpMethod, pattern: String = "", callback: HttpCallback) { + fun after(method: HttpMethod, pattern: String = "", callback: HttpCallbackType) { use(AfterHandler(method, pattern, callback)) } - fun after(pattern: String, callback: HttpCallback) { + fun after(pattern: String, callback: HttpCallbackType) { use(AfterHandler(pattern, callback)) } fun before( predicate: HttpPredicate = HttpPredicate(), - callback: HttpCallback + callback: HttpCallbackType ) { use(BeforeHandler(predicate, callback)) } @@ -119,64 +119,64 @@ class HandlerBuilder(var handlers: List = emptyList()) { pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - callback: HttpCallback, + callback: HttpCallbackType, ) { use(BeforeHandler(methods, pattern, exception, status, callback)) } - fun before(method: HttpMethod, pattern: String = "", callback: HttpCallback) { + fun before(method: HttpMethod, pattern: String = "", callback: HttpCallbackType) { use(BeforeHandler(method, pattern, callback)) } - fun before(pattern: String, callback: HttpCallback) { + fun before(pattern: String, callback: HttpCallbackType) { use(BeforeHandler(pattern, callback)) } fun exception( - exception: KClass, clear: Boolean = true, callback: HttpExceptionCallback + exception: KClass, clear: Boolean = true, callback: HttpExceptionCallbackType ) { use(ExceptionHandler(exception, clear, callback)) } inline fun exception( - clear: Boolean = true, noinline callback: HttpExceptionCallback, + clear: Boolean = true, noinline callback: HttpExceptionCallbackType, ) { use(ExceptionHandler(T::class, clear, callback)) } - fun get(pattern: String = "", callback: HttpCallback) { + fun get(pattern: String = "", callback: HttpCallbackType) { use(Get(pattern, callback)) } - fun ws(pattern: String = "", callback: HttpCallback) { + fun ws(pattern: String = "", callback: HttpCallbackType) { use(Ws(pattern, callback)) } - fun head(pattern: String = "", callback: HttpCallback) { + fun head(pattern: String = "", callback: HttpCallbackType) { use(Head(pattern, callback)) } - fun post(pattern: String = "", callback: HttpCallback) { + fun post(pattern: String = "", callback: HttpCallbackType) { use(Post(pattern, callback)) } - fun put(pattern: String = "", callback: HttpCallback) { + fun put(pattern: String = "", callback: HttpCallbackType) { use(Put(pattern, callback)) } - fun delete(pattern: String = "", callback: HttpCallback) { + fun delete(pattern: String = "", callback: HttpCallbackType) { use(Delete(pattern, callback)) } - fun trace(pattern: String = "", callback: HttpCallback) { + fun trace(pattern: String = "", callback: HttpCallbackType) { use(Trace(pattern, callback)) } - fun options(pattern: String = "", callback: HttpCallback) { + fun options(pattern: String = "", callback: HttpCallbackType) { use(Options(pattern, callback)) } - fun patch(pattern: String = "", callback: HttpCallback) { + fun patch(pattern: String = "", callback: HttpCallbackType) { use(Patch(pattern, callback)) } } diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt index a8f67c8c0d..5a85a6a322 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/Handlers.kt @@ -13,9 +13,12 @@ import java.lang.IllegalStateException import java.math.BigInteger import java.security.cert.X509Certificate -// TODO Inline these type aliases and reuse their names in interfaces (better for extension) -typealias HttpCallback = HttpContext.() -> HttpContext -typealias HttpExceptionCallback = HttpContext.(T) -> HttpContext +typealias HttpCallbackType = HttpContext.() -> HttpContext +typealias HttpExceptionCallbackType = HttpContext.(T) -> HttpContext + +interface HttpCallback : (HttpContext) -> HttpContext +// TODO Use this type to implement the RFC 7807 exception handler +interface HttpExceptionCallback : (HttpContext, T) -> HttpContext private val logger: Logger by lazy { Logger(HttpHandler::class.java.packageName) } private val BODY_TYPES_NAMES: String by lazy { @@ -23,21 +26,21 @@ private val BODY_TYPES_NAMES: String by lazy { bodyTypes.joinToString(", ") { it.simpleName.toString() } } -internal fun toCallback(block: HttpCallback): (Context) -> Context = +internal fun toCallback(block: HttpCallbackType): (Context) -> Context = { context -> HttpContext(context).block() } internal fun toCallback( - block: HttpExceptionCallback + block: HttpExceptionCallbackType ): (Context, E) -> Context = { context, e -> HttpContext(context).block(e) } -fun HttpCallback.process( +fun HttpCallbackType.process( request: HttpRequest, attributes: Map<*, *> = emptyMap() ): HttpContext = this(HttpContext(request = request, attributes = attributes)) -fun HttpCallback.process( +fun HttpCallbackType.process( method: HttpMethod = GET, protocol: HttpProtocol = HTTP, host: String = "localhost", @@ -91,31 +94,31 @@ fun path(contextPath: String = "", handlers: List): PathHandler = PathHandler(contextPath, it) } -fun Get(pattern: String = "", callback: HttpCallback): OnHandler = +fun Get(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(GET, pattern, callback) -fun Ws(pattern: String = "", callback: HttpCallback): OnHandler = +fun Ws(pattern: String = "", callback: HttpCallbackType): OnHandler = Get(pattern, callback) -fun Head(pattern: String = "", callback: HttpCallback): OnHandler = +fun Head(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(HEAD, pattern, callback) -fun Post(pattern: String = "", callback: HttpCallback): OnHandler = +fun Post(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(POST, pattern, callback) -fun Put(pattern: String = "", callback: HttpCallback): OnHandler = +fun Put(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(PUT, pattern, callback) -fun Delete(pattern: String = "", callback: HttpCallback): OnHandler = +fun Delete(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(DELETE, pattern, callback) -fun Trace(pattern: String = "", callback: HttpCallback): OnHandler = +fun Trace(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(TRACE, pattern, callback) -fun Options(pattern: String = "", callback: HttpCallback): OnHandler = +fun Options(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(OPTIONS, pattern, callback) -fun Patch(pattern: String = "", callback: HttpCallback): OnHandler = +fun Patch(pattern: String = "", callback: HttpCallbackType): OnHandler = OnHandler(PATCH, pattern, callback) fun bodyToBytes(body: Any): ByteArray = diff --git a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/OnHandler.kt b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/OnHandler.kt index 0ef081b185..1a91d72476 100644 --- a/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/OnHandler.kt +++ b/http/http_handlers/src/main/kotlin/com/hexagonkt/http/handlers/OnHandler.kt @@ -9,7 +9,7 @@ import kotlin.reflect.KClass data class OnHandler( override val handlerPredicate: HttpPredicate = HttpPredicate(), - val block: HttpCallback, + val block: HttpCallbackType, ) : HttpHandler, Handler by OnHandler(handlerPredicate, toCallback(block)) { constructor( @@ -17,14 +17,14 @@ data class OnHandler( pattern: String = "", exception: KClass? = null, status: HttpStatus? = null, - block: HttpCallback, + block: HttpCallbackType, ) : this(HttpPredicate(methods, pattern, exception, status), block) - constructor(method: HttpMethod, pattern: String = "", block: HttpCallback) : + constructor(method: HttpMethod, pattern: String = "", block: HttpCallbackType) : this(setOf(method), pattern, block = block) - constructor(pattern: String, block: HttpCallback) : + constructor(pattern: String, block: HttpCallbackType) : this(emptySet(), pattern, block = block) override fun addPrefix(prefix: String): HttpHandler = diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt index d4b0714324..4ca3df6ba5 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/ClientTest.kt @@ -17,7 +17,7 @@ import com.hexagonkt.http.model.HttpProtocol.HTTPS import com.hexagonkt.http.model.INTERNAL_SERVER_ERROR_500 import com.hexagonkt.http.model.OK_200 import com.hexagonkt.http.server.* -import com.hexagonkt.http.handlers.HttpCallback +import com.hexagonkt.http.handlers.HttpCallbackType import com.hexagonkt.http.handlers.HttpHandler import com.hexagonkt.http.handlers.path import com.hexagonkt.http.test.BaseTest @@ -42,7 +42,7 @@ abstract class ClientTest( final override val serverSettings: HttpServerSettings = HttpServerSettings(), ) : BaseTest() { - private var callback: HttpCallback = { this } + private var callback: HttpCallbackType = { this } override val handler: HttpHandler = path { post("*") { callback() } diff --git a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt index 0c80eaeb6d..9d7d90111c 100644 --- a/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt +++ b/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/SamplesTest.kt @@ -554,7 +554,7 @@ abstract class SamplesTest( @Test fun mockRequest() { // mockRequest // Test callback (basically, a handler without a predicate) - val callback: HttpCallback = { + val callback: HttpCallbackType = { val fakeAttribute = attributes["fake"] val fakeHeader = request.headers["fake"]?.value ok("Callback result $fakeAttribute $fakeHeader") diff --git a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeRequestCallback.kt b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeRequestCallback.kt index d4f3cfe6d5..8874025bd1 100644 --- a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeRequestCallback.kt +++ b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeRequestCallback.kt @@ -1,10 +1,11 @@ package com.hexagonkt.rest +import com.hexagonkt.http.handlers.HttpCallback import com.hexagonkt.http.handlers.HttpContext import com.hexagonkt.serialization.SerializationManager import com.hexagonkt.serialization.serialize -class SerializeRequestCallback: (HttpContext) -> HttpContext { +class SerializeRequestCallback : HttpCallback { // TODO Short circuit if body is empty override fun invoke(context: HttpContext): HttpContext = diff --git a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt index 31d7027940..5403cf263e 100644 --- a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt +++ b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt @@ -1,11 +1,12 @@ package com.hexagonkt.rest +import com.hexagonkt.http.handlers.HttpCallback import com.hexagonkt.http.handlers.HttpContext import com.hexagonkt.http.model.ContentType import com.hexagonkt.serialization.SerializationManager import com.hexagonkt.serialization.serialize -class SerializeResponseCallback: (HttpContext) -> HttpContext { +class SerializeResponseCallback: HttpCallback { fun HttpContext.accept(): List = request.accept.ifEmpty { response.contentType?.let(::listOf) ?: emptyList() } diff --git a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/OpenApiHandler.kt b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/OpenApiHandler.kt index 5207b23f43..45768a25a1 100644 --- a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/OpenApiHandler.kt +++ b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/OpenApiHandler.kt @@ -19,8 +19,6 @@ import io.swagger.v3.oas.models.security.SecurityScheme import io.swagger.v3.oas.models.security.SecurityScheme.Type import io.swagger.v3.parser.OpenAPIV3Parser -// TODO Validate bodies with vertx-json-schema -// TODO Check https://github.com/swagger-api/swagger-parser for route verification internal class OpenApiHandler(pathToSpec: String) { private val openAPIParser = OpenAPIV3Parser() @@ -48,7 +46,7 @@ internal class OpenApiHandler(pathToSpec: String) { private fun createHandler(method: HttpMethod, path: String, operation: Operation): HttpHandler = OnHandler(method, path, handleRequest(operation)) - private fun handleRequest(operation: Operation): HttpCallback = + private fun handleRequest(operation: Operation): HttpCallbackType = { verifyAuth(operation, this) ?: verifyParams(operation, this) diff --git a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/VerifySpecCallback.kt b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/VerifySpecCallback.kt index 8b2c8f7401..485610207f 100644 --- a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/VerifySpecCallback.kt +++ b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/openapi/VerifySpecCallback.kt @@ -8,6 +8,7 @@ import com.atlassian.oai.validator.model.Request.Method import com.atlassian.oai.validator.model.SimpleRequest import com.atlassian.oai.validator.model.SimpleResponse import com.atlassian.oai.validator.report.ValidationReport +import com.hexagonkt.http.handlers.HttpCallback import com.hexagonkt.http.handlers.HttpContext import com.hexagonkt.http.model.ContentType import com.hexagonkt.http.model.HttpMethod @@ -18,7 +19,7 @@ import kotlin.jvm.optionals.getOrNull /** * Callback that verifies server calls comply with a given OpenAPI spec. */ -class VerifySpecCallback(spec: URL) : (HttpContext) -> HttpContext { +class VerifySpecCallback(spec: URL) : HttpCallback { private val messagePrefix: String = "\n- " private val validator: OpenApiInteractionValidator = From 6f496d346c63888891a371068f5300daeb42522f Mon Sep 17 00:00:00 2001 From: jaguililla Date: Thu, 4 Jan 2024 20:53:36 +0100 Subject: [PATCH 08/36] Update dependencies --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 74caab3f24..194e4629ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,7 +35,7 @@ kotlinVersion=1.9.22 dokkaVersion=1.9.10 mockkVersion=1.13.8 junitVersion=5.10.1 -gatlingVersion=3.10.2 +gatlingVersion=3.10.3 jmhVersion=1.37 mkdocsMaterialVersion=9.5.3 mermaidDokkaVersion=0.4.4 @@ -56,11 +56,11 @@ jettyVersion=12.0.5 swaggerRequestValidatorVersion=2.39.0 # logging -slf4jVersion=2.0.9 +slf4jVersion=2.0.10 logbackVersion=1.4.14 # serialization -jacksonVersion=2.16.0 +jacksonVersion=2.16.1 dslJsonVersion=2.0.2 # templates_freemarker From 430bde920a08b5c84251de9813e59c524393f19d Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sun, 7 Jan 2024 15:37:07 +0100 Subject: [PATCH 09/36] Improve serialization callback --- core/api/core.api | 1 + .../com/hexagonkt/core/media/MediaTypes.kt | 2 ++ .../com/hexagonkt/core/media/MediaTypeTest.kt | 2 ++ .../rest/SerializeResponseCallback.kt | 21 +++++++++++++------ http/rest_tools/build.gradle.kts | 9 +++++++- .../kotlin/com/hexagonkt/rest/tools/Http.kt | 12 +++++++++++ 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index f2b2c5f79f..d211675d48 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -340,6 +340,7 @@ public final class com/hexagonkt/core/media/MediaTypeGroup : java/lang/Enum { public final class com/hexagonkt/core/media/MediaTypesKt { public static final fun extensionsOf (Lcom/hexagonkt/core/media/MediaType;)Ljava/util/List; + public static final fun getANY_MEDIA ()Lcom/hexagonkt/core/media/MediaType; public static final fun getAPPLICATION_7Z ()Lcom/hexagonkt/core/media/MediaType; public static final fun getAPPLICATION_AVRO ()Lcom/hexagonkt/core/media/MediaType; public static final fun getAPPLICATION_BZIP ()Lcom/hexagonkt/core/media/MediaType; diff --git a/core/src/main/kotlin/com/hexagonkt/core/media/MediaTypes.kt b/core/src/main/kotlin/com/hexagonkt/core/media/MediaTypes.kt index 7efb8de3b9..8b493182d7 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/media/MediaTypes.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/media/MediaTypes.kt @@ -9,6 +9,8 @@ import kotlin.io.path.extension val MEDIA_TYPE_FORMAT: Regex by lazy { """\*|([\w+.-]+)""".toRegex() } +val ANY_MEDIA: MediaType by lazy { MediaType(ANY, "*") } + val APPLICATION_AVRO: MediaType by lazy { MediaType(APPLICATION, "avro") } val APPLICATION_CBOR: MediaType by lazy { MediaType(APPLICATION, "cbor") } val APPLICATION_JSON: MediaType by lazy { MediaType(APPLICATION, "json") } diff --git a/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypeTest.kt b/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypeTest.kt index 068ff4c886..17a5ed6510 100644 --- a/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypeTest.kt +++ b/core/src/test/kotlin/com/hexagonkt/core/media/MediaTypeTest.kt @@ -19,6 +19,8 @@ internal class MediaTypeTest { } @Test fun `Media types without extensions are correct`() { + assertEquals("*/*", ANY_MEDIA.fullType) + assertEquals("multipart/alternative", MULTIPART_ALTERNATIVE.fullType) assertEquals("multipart/appledouble", MULTIPART_APPLEDOUBLE.fullType) assertEquals("multipart/digest", MULTIPART_DIGEST.fullType) diff --git a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt index 5403cf263e..94552ea672 100644 --- a/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt +++ b/http/rest/src/main/kotlin/com/hexagonkt/rest/SerializeResponseCallback.kt @@ -1,5 +1,6 @@ package com.hexagonkt.rest +import com.hexagonkt.core.media.ANY_MEDIA import com.hexagonkt.http.handlers.HttpCallback import com.hexagonkt.http.handlers.HttpContext import com.hexagonkt.http.model.ContentType @@ -8,16 +9,24 @@ import com.hexagonkt.serialization.serialize class SerializeResponseCallback: HttpCallback { - fun HttpContext.accept(): List = - request.accept.ifEmpty { response.contentType?.let(::listOf) ?: emptyList() } + private companion object { + val anyContentType = ContentType(ANY_MEDIA) + val emptyBodies = setOf("", ByteArray(0)) + } - // TODO Short circuit if body is empty - override fun invoke(context: HttpContext): HttpContext = - context.accept() + override fun invoke(context: HttpContext): HttpContext { + val responseBody = context.response.body + + if (responseBody in emptyBodies) + return context + + return (context.request.accept - anyContentType) + .ifEmpty { context.response.contentType?.let(::listOf) ?: emptyList() } .associateWith { SerializationManager.formatOfOrNull(it.mediaType) } .mapNotNull { (k, v) -> v?.let { k to it } } .firstOrNull() - ?.let { (ct, sf) -> ct to context.response.body.serialize(sf) } + ?.let { (ct, sf) -> ct to responseBody.serialize(sf) } ?.let { (ct, c) -> context.send(body = c, contentType = ct) } ?: context + } } diff --git a/http/rest_tools/build.gradle.kts b/http/rest_tools/build.gradle.kts index eecbd14b3a..ae42438252 100644 --- a/http/rest_tools/build.gradle.kts +++ b/http/rest_tools/build.gradle.kts @@ -12,12 +12,19 @@ apply(from = "$rootDir/gradle/detekt.gradle") description = "Tools to test and document REST services." dependencies { + val guavaVersion = "33.0.0-jre" + val slf4jVersion = properties["slf4jVersion"] val swaggerRequestValidatorVersion = properties["swaggerRequestValidatorVersion"] "api"(project(":http:rest")) "api"(project(":http:http_server")) "api"(project(":http:http_client")) - "api"("com.atlassian.oai:swagger-request-validator-core:$swaggerRequestValidatorVersion") + "api"("org.slf4j:slf4j-api:$slf4jVersion") + "api"("com.google.guava:guava:$guavaVersion") + "api"("com.atlassian.oai:swagger-request-validator-core:$swaggerRequestValidatorVersion") { + exclude(group = "org.slf4j") + exclude(group = "com.google.guava") + } "testImplementation"(project(":http:http_client_jetty")) "testImplementation"(project(":http:http_server_jetty")) diff --git a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/Http.kt b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/Http.kt index 1396f97986..2d5e2468f7 100644 --- a/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/Http.kt +++ b/http/rest_tools/src/main/kotlin/com/hexagonkt/rest/tools/Http.kt @@ -23,6 +23,8 @@ data class Http( val httpHeaders: Map = emptyMap(), val sslSettings: SslSettings? = SslSettings(), val handler: HttpHandler? = serializeHandler, + val authorization: Authorization? = null, + val followRedirects: Boolean = false ) { companion object { val serializeHandler: HttpHandler = BeforeHandler("*", SerializeRequestCallback()) @@ -37,6 +39,8 @@ data class Http( headers = toHeaders(httpHeaders), insecure = true, sslSettings = sslSettings, + authorization = authorization, + followRedirects = followRedirects ) private val client = HttpClient(adapter, settings, handler = handler) @@ -100,6 +104,14 @@ data class Http( assertStatus(SUCCESS) } + fun assertContentType(contentType: ContentType) { + assert(this.contentType == contentType) + } + + fun assertContentType(mediaType: MediaType) { + assert(contentType == ContentType(mediaType)) + } + fun assertBody(body: Any) { assert(body == lastResponse.body) } From e2e859049e048012982fb089103d7327aaccbed2 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Wed, 10 Jan 2024 19:31:49 +0100 Subject: [PATCH 10/36] Rename GitHub organization (code) --- .../main/kotlin/com/hexagonkt/core/Data.kt | 32 +++++++++---------- .../main/kotlin/com/hexagonkt/core/I18n.kt | 8 ++--- .../main/kotlin/com/hexagonkt/core/Uuids.kt | 8 ++--- .../kotlin/com/hexagonkt/core/text/Glob.kt | 6 ++-- .../kotlin/com/hexagonkt/core/text/Strings.kt | 20 ++++++------ 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/core/src/main/kotlin/com/hexagonkt/core/Data.kt b/core/src/main/kotlin/com/hexagonkt/core/Data.kt index 950cce521c..dac385f552 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Data.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Data.kt @@ -3,7 +3,7 @@ package com.hexagonkt.core import kotlin.reflect.KProperty1 /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param keys . @@ -29,7 +29,7 @@ inline fun Map<*, *>.getPath(vararg keys: Any): T? { } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param name . @@ -39,7 +39,7 @@ inline fun Map<*, *>.requirePath(vararg name: Any): T = this.getPath(*name) ?: error("$name required key not found") /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param fields . * @return . @@ -48,7 +48,7 @@ fun fieldsMapOf(vararg fields: Pair, *>): Map fieldsMapOfNotNull(vararg fields: Pair, *>): Map< fieldsMapOf(*fields).filterValues { it != null } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param pairs . * @return . @@ -66,7 +66,7 @@ fun mapOfNotNull(vararg pairs: Pair): Map = mapOf(*pairs).filterValues { it != null } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param name . @@ -76,7 +76,7 @@ fun Map.require(name: K): V = this[name] ?: error("$name required key not found") /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param T . * @param key . @@ -86,7 +86,7 @@ inline operator fun Map<*, *>.get(key: KProperty1<*, *>): T? = this[key.name] as? T /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param T . * @param key . @@ -97,7 +97,7 @@ inline fun Map<*, *>.getOrDefault(key: KProperty1<*, *>, defau this[key] ?: default /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * Mermaid test: * ```mermaid @@ -124,7 +124,7 @@ fun merge(mapA: Map<*, *>, mapB: Map<*, *>): Map<*, *> = } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param maps . * @return . @@ -133,7 +133,7 @@ fun merge(maps: Collection>): Map<*, *> = maps.reduce { a, b -> merge(a, b) } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -142,7 +142,7 @@ fun Map>.pairs(): Collection> = flatMap { (k, v) -> v.map { k to it } } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -151,7 +151,7 @@ fun Map.filterNotEmpty(): Map = this.filterValues(::notEmpty).mapValues { (_, v) -> v ?: fail } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -160,7 +160,7 @@ fun Collection.filterNotEmpty(): Collection = this.filter(::notEmpty).map { it ?: fail } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -176,7 +176,7 @@ fun Map<*, *>.filterNotEmptyRecursive(): Map<*, *> = .filterNotEmpty() /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -192,7 +192,7 @@ fun Collection<*>.filterNotEmptyRecursive(): Collection<*> = .filterNotEmpty() /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param value . * @return . diff --git a/core/src/main/kotlin/com/hexagonkt/core/I18n.kt b/core/src/main/kotlin/com/hexagonkt/core/I18n.kt index 4303883645..d7c835406d 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/I18n.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/I18n.kt @@ -19,7 +19,7 @@ val currencyCodes: Set by lazy { } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param locale . * @return . @@ -29,7 +29,7 @@ inline fun resourceBundle( resourceBundle(T::class, locale) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param type . * @param locale . @@ -40,7 +40,7 @@ fun resourceBundle( ResourceBundle.getBundle(type.java.name, locale) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param language . * @param country . @@ -56,7 +56,7 @@ fun localeOf(language: String = "", country: String = ""): Locale { } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param language . * @param country . diff --git a/core/src/main/kotlin/com/hexagonkt/core/Uuids.kt b/core/src/main/kotlin/com/hexagonkt/core/Uuids.kt index 2763ae899b..8c105ffe13 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/Uuids.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/Uuids.kt @@ -6,7 +6,7 @@ import java.nio.ByteBuffer import java.util.* /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -19,7 +19,7 @@ fun UUID.bytes(): ByteArray = } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -28,7 +28,7 @@ fun UUID.toBase64(): String = bytes().encodeToBase64() /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param text . * @return . @@ -38,7 +38,7 @@ fun uuid(text: String): UUID = else uuid(text.decodeBase64()) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param bytes . * @return . diff --git a/core/src/main/kotlin/com/hexagonkt/core/text/Glob.kt b/core/src/main/kotlin/com/hexagonkt/core/text/Glob.kt index b6cc210ea3..08d5690a90 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/text/Glob.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/text/Glob.kt @@ -4,13 +4,13 @@ import kotlin.IllegalArgumentException import java.util.regex.PatternSyntaxException /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @property pattern . */ data class Glob(val pattern: String) { - /** [TODO](https://github.com/hexagonkt/hexagon/issues/271). */ + /** [TODO](https://github.com/hexagontk/hexagon/issues/271). */ val regex: Regex = try { globToRegex(pattern).toRegex() @@ -20,7 +20,7 @@ data class Glob(val pattern: String) { } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param text . * @return . diff --git a/core/src/main/kotlin/com/hexagonkt/core/text/Strings.kt b/core/src/main/kotlin/com/hexagonkt/core/text/Strings.kt index 02a36151aa..3da22e2da3 100644 --- a/core/src/main/kotlin/com/hexagonkt/core/text/Strings.kt +++ b/core/src/main/kotlin/com/hexagonkt/core/text/Strings.kt @@ -64,7 +64,7 @@ fun String.filterVars(parameters: Map<*, *>): String = ) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param prefix . @@ -105,7 +105,7 @@ fun String.decodeBase64(): ByteArray = base64Decoder.decode(this) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param T . @@ -136,7 +136,7 @@ fun String.parse(type: KClass): T = } as T /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param T . @@ -158,7 +158,7 @@ fun String.stripAnsi(): String = replace(Ansi.REGEX, "") /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -167,7 +167,7 @@ fun String.toStream(): InputStream = ByteArrayInputStream(this.toByteArray()) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param count . @@ -178,7 +178,7 @@ fun String.prependIndent(count: Int = 4, pad: String = " "): String = this.prependIndent(pad.repeat(count)) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param T . @@ -189,7 +189,7 @@ fun > String.toEnum(converter: (String) -> T): T = uppercase().replace(" ", "_").let(converter) /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param T . @@ -205,7 +205,7 @@ fun > String.toEnumOrNull(converter: (String) -> T): T? = } /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @param text . @@ -236,7 +236,7 @@ fun String.banner(bannerDelimiter: String = "*"): String = // TODO These and other implemented methods can fit in a Effects.kt file /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @receiver . * @return . @@ -245,7 +245,7 @@ fun String.stripAccents(): String = Normalizer.normalize(this, NFD).replace("\\p{M}".toRegex(), "") /** - * [TODO](https://github.com/hexagonkt/hexagon/issues/271). + * [TODO](https://github.com/hexagontk/hexagon/issues/271). * * @param bytes . * @return . From 63381de1d0e957e7a8339e4a5e3cda10ee2517f7 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Wed, 10 Jan 2024 19:44:21 +0100 Subject: [PATCH 11/36] Rename GitHub organization (documentation) --- README.md | 20 ++++++------- contributing.md | 26 ++++++++-------- http/http_client/README.md | 2 +- http/http_handlers/README.md | 2 +- http/http_server/README.md | 2 +- .../src/main/resources/assets/index.html | 30 +++++++++---------- site/footer.txt | 4 +-- site/mkdocs.yml | 16 +++++----- site/mkdocs/index.html | 4 +-- site/mkdocs/main.html | 6 ++-- site/pages/examples/example_projects.md | 8 ++--- site/pages/examples/http_client_examples.md | 10 +++---- site/pages/examples/http_server_examples.md | 14 ++++----- site/pages/examples/templates_examples.md | 4 +-- site/pages/gradle.md | 6 ++-- site/pages/help.md | 8 ++--- site/pages/planning.md | 6 ++-- site/pages/quick_start.md | 4 +-- 18 files changed, 86 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index 2ef834bdab..d21390e699 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@

The atoms of your platform

- + GitHub Actions + src="https://github.com/hexagontk/hexagon/workflows/Release/badge.svg" /> Coverage @@ -142,8 +142,8 @@ fun main() { 4. Run the service and view the results at: [http://localhost:2010/hello][Endpoint] -[Gradle Starter]: https://github.com/hexagonkt/gradle_starter -[Maven Starter]: https://github.com/hexagonkt/maven_starter +[Gradle Starter]: https://github.com/hexagontk/gradle_starter +[Maven Starter]: https://github.com/hexagontk/maven_starter [Setup Gradle]: https://kotlinlang.org/docs/reference/using-gradle.html [Setup Maven]: https://kotlinlang.org/docs/reference/using-maven.html [Endpoint]: http://localhost:2010/hello @@ -463,15 +463,15 @@ Thanks to all project's [contributors]! [![CodeTriage](https://www.codetriage.com/hexagonkt/hexagon/badges/users.svg)][CodeTriage] -[give it a star]: https://github.com/hexagonkt/hexagon/stargazers +[give it a star]: https://github.com/hexagontk/hexagon/stargazers [@hexagontk]: https://twitter.com/hexagontk [Slack]: https://kotlinlang.slack.com/messages/hexagon -[issues]: https://github.com/hexagonkt/hexagon/issues +[issues]: https://github.com/hexagontk/hexagon/issues [reactions]: https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments -[contributing]: https://github.com/hexagonkt/hexagon/contribute -[Organization Board]: https://github.com/orgs/hexagonkt/projects/2 -[contributors]: https://github.com/hexagonkt/hexagon/graphs/contributors -[CodeTriage]: https://www.codetriage.com/hexagonkt/hexagon +[contributing]: https://github.com/hexagontk/hexagon/contribute +[Organization Board]: https://github.com/orgs/hexagontk/projects/2 +[contributors]: https://github.com/hexagontk/hexagon/graphs/contributors +[CodeTriage]: https://www.codetriage.com/hexagontk/hexagon ## License diff --git a/contributing.md b/contributing.md index cbda36f021..4d423f0d6c 100644 --- a/contributing.md +++ b/contributing.md @@ -10,19 +10,19 @@ You can also ask any question, make suggestions or complaints at the project's [Slack channel][Slack]. You can also be up-to-date of project's news following [@hexagontk] on X (Twitter). -[discussion]: https://github.com/hexagonkt/hexagon/discussions +[discussion]: https://github.com/hexagontk/hexagon/discussions [Slack]: https://kotlinlang.slack.com/messages/hexagon [@hexagontk]: https://twitter.com/hexagontk ## Report a Bug To file a bug, create an issue with the [bug template]. -[bug template]: https://github.com/hexagonkt/hexagon/issues/new?template=bug.md +[bug template]: https://github.com/hexagontk/hexagon/issues/new?template=bug.md ## Request a Feature Create a new issue using the [enhancement template] to file an improvement. -[enhancement template]: https://github.com/hexagonkt/hexagon/issues/new?template=enhancement.md +[enhancement template]: https://github.com/hexagontk/hexagon/issues/new?template=enhancement.md ## Contribution Steps 1. You can check available tasks in the [Organization Board]. Issues with the [help wanted] tag in @@ -43,14 +43,14 @@ Create a new issue using the [enhancement template] to file an improvement. module definition). 7. Follow the commit rules defined at the [commit guidelines]. -[Organization Board]: https://github.com/orgs/hexagonkt/projects/2 -[help wanted]: https://github.com/hexagonkt/hexagon/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22 -[pull request template]: https://github.com/hexagonkt/.github/blob/master/pull_request_template.md +[Organization Board]: https://github.com/orgs/hexagontk/projects/2 +[help wanted]: https://github.com/hexagontk/hexagon/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22 +[pull request template]: https://github.com/hexagontk/.github/blob/master/pull_request_template.md [IntelliJ]: https://www.jetbrains.com/idea [Editor Config]: https://editorconfig.org [Kotlin Coding Conventions]: https://kotlinlang.org/docs/reference/coding-conventions.html -[commit guidelines]: https://github.com/hexagonkt/.github/blob/master/commits.md -[ideas]: https://github.com/hexagonkt/hexagon/discussions/categories/ideas +[commit guidelines]: https://github.com/hexagontk/.github/blob/master/commits.md +[ideas]: https://github.com/hexagontk/hexagon/discussions/categories/ideas ## Project Structure The Hexagon project is composed of several modules. Most of the modules publish libraries for their @@ -60,16 +60,16 @@ Aside of that kind of modules, you can also find infrastructure modules: compone project itself. These are internal modules not intended to be directly used by users (like the [starters] or the [site]). -[Hexagon Structure]: https://github.com/hexagonkt/hexagon/blob/master/README.md#hexagon-structure -[starters]: https://github.com/hexagonkt/hexagon/blob/master/starters/README.md -[site]: https://github.com/hexagonkt/hexagon/blob/master/site/README.md +[Hexagon Structure]: https://github.com/hexagontk/hexagon/blob/master/README.md#hexagon-structure +[starters]: https://github.com/hexagontk/hexagon/blob/master/starters/README.md +[site]: https://github.com/hexagontk/hexagon/blob/master/site/README.md ## Local Setup Hexagon build process requires a JDK 21+ to compile. You can check the required software, build the project, generate the documentation and install it in your local repository typing: ```bash -git clone https://github.com/hexagonkt/hexagon.git +git clone https://github.com/hexagontk/hexagon.git cd hexagon ./gradlew setUp clean build ./gradlew buildSite publishToMavenLocal @@ -134,7 +134,7 @@ Commit messages can be filtered by types (check the [commit guidelines]) for det git log 1.2.0...1.3.0 \ --date=iso8601 \ --reverse \ - --pretty=format:'* %ad %ar <%an %ae> [View](http://github.com/hexagonkt/hexagon/commit/%H) · %s' \ + --pretty=format:'* %ad %ar <%an %ae> [View](http://github.com/hexagontk/hexagon/commit/%H) · %s' \ >>CHANGELOG.md git log 1.2.0...1.3.0 --date=iso8601 --reverse --pretty=format:'%an %ae'|sort|uniq >>CHANGELOG.md diff --git a/http/http_client/README.md b/http/http_client/README.md index e5a9614dce..1e01585aa9 100644 --- a/http/http_client/README.md +++ b/http/http_client/README.md @@ -63,7 +63,7 @@ Check the details in the following code fragment: You can also check the [full test] for more details. -[full test]: https://github.com/hexagonkt/hexagon/blob/master/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/CookiesTest.kt +[full test]: https://github.com/hexagontk/hexagon/blob/master/http/http_test/src/main/kotlin/com/hexagonkt/http/test/examples/CookiesTest.kt # Multipart (forms and files) Using the HTTP client you can send MIME multipart parts to the server. You can use it to post forms diff --git a/http/http_handlers/README.md b/http/http_handlers/README.md index be496a5529..bf9ce177d0 100644 --- a/http/http_handlers/README.md +++ b/http/http_handlers/README.md @@ -378,7 +378,7 @@ To do this kind of tests without creating a custom server (using the real produc Check the [tests of the starter projects]. [tests of the starter projects]: -https://github.com/hexagonkt/gradle_starter/blob/master/src/test/kotlin/ApplicationTest.kt +https://github.com/hexagontk/gradle_starter/blob/master/src/test/kotlin/ApplicationTest.kt ## Mocking Calls To unit test callbacks and handlers you can create test calls with hardcoded requests without diff --git a/http/http_server/README.md b/http/http_server/README.md index fae94d34a1..56a768bf87 100644 --- a/http/http_server/README.md +++ b/http/http_server/README.md @@ -373,7 +373,7 @@ To do this kind of tests without creating a custom server (using the real produc Check the [tests of the starter projects]. [tests of the starter projects]: -https://github.com/hexagonkt/gradle_starter/blob/master/src/test/kotlin/ApplicationTest.kt +https://github.com/hexagontk/gradle_starter/blob/master/src/test/kotlin/ApplicationTest.kt ## Mocking Calls To unit test callbacks and handlers you can create test calls with hardcoded requests without diff --git a/http/http_test/src/main/resources/assets/index.html b/http/http_test/src/main/resources/assets/index.html index b21e834a02..3d8a08c304 100644 --- a/http/http_test/src/main/resources/assets/index.html +++ b/http/http_test/src/main/resources/assets/index.html @@ -102,7 +102,7 @@

@@ -150,7 +150,7 @@

Simple to Use

Community

@@ -265,30 +265,30 @@

Community

- Made with by - OSS contributors. Licensed under + Made with by + OSS contributors. Licensed under MIT License
Star + aria-label="Star hexagontk/hexagon on GitHub">Star Watch + aria-label="Watch hexagontk/hexagon on GitHub">Watch Fork + aria-label="Fork hexagontk/hexagon on GitHub">Fork diff --git a/site/footer.txt b/site/footer.txt index 3930aa282c..f953bb97da 100644 --- a/site/footer.txt +++ b/site/footer.txt @@ -2,6 +2,6 @@ Made with by -OSS contributors. -Licensed under +OSS contributors. +Licensed under MIT License diff --git a/site/mkdocs.yml b/site/mkdocs.yml index 7535f41da7..b692dc2874 100644 --- a/site/mkdocs.yml +++ b/site/mkdocs.yml @@ -12,11 +12,11 @@ copyright: > by - OSS contributors. Licensed - under MIT License + OSS contributors. Licensed + under MIT License -repo_name: hexagonkt/hexagon -repo_url: https://github.com/hexagonkt/hexagon +repo_name: hexagontk/hexagon +repo_url: https://github.com/hexagontk/hexagon edit_uri: "" docs_dir: build/content @@ -69,8 +69,8 @@ nav: - Community: - Help and Support: help.md - Planning: planning.md - - Contributing ↗: https://github.com/hexagonkt/hexagon/contribute - - GitHub ↗: https://github.com/hexagonkt + - Contributing ↗: https://github.com/hexagontk/hexagon/contribute + - GitHub ↗: https://github.com/hexagontk - Dev.to ↗: https://dev.to/hexagontk - LibHunt ↗: https://kotlin.libhunt.com/hexagon-alternatives - StackShare ↗: https://stackshare.io/hexagon @@ -116,7 +116,7 @@ extra_javascript: - https://platform.twitter.com/widgets.js extra: - repo: hexagonkt/hexagon + repo: hexagontk/hexagon theme_color: '#135AA1' site_keywords: Hexagon, microservices, Kotlin, RabbitMQ, MongoDB, JVM, Web, Toolkit, Framework site_long_description: > @@ -130,7 +130,7 @@ extra: twitter_user: hexagontk social: - icon: fontawesome/brands/github - link: https://github.com/hexagonkt + link: https://github.com/hexagontk - icon: fontawesome/brands/dev link: https://dev.to/hexagontk - icon: fontawesome/brands/x-twitter diff --git a/site/mkdocs/index.html b/site/mkdocs/index.html index 14757fa211..42d3772b8c 100644 --- a/site/mkdocs/index.html +++ b/site/mkdocs/index.html @@ -12,10 +12,10 @@

Hexagon
- + GitHub Actions + src="https://github.com/hexagontk/hexagon/workflows/Release/badge.svg" /> Coverage diff --git a/site/mkdocs/main.html b/site/mkdocs/main.html index 6130d174e9..4da7eca085 100644 --- a/site/mkdocs/main.html +++ b/site/mkdocs/main.html @@ -99,15 +99,15 @@