Last active
November 20, 2023 11:57
-
-
Save lasteris/859c75bcd8640b15a27655cb0784c8b1 to your computer and use it in GitHub Desktop.
vertx-cyrrillyc-encode-problem
This file contains hidden or 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
| import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | |
| import org.gradle.api.tasks.testing.logging.TestLogEvent.* | |
| plugins { | |
| java | |
| application | |
| id("com.github.johnrengelman.shadow") version "7.1.2" | |
| } | |
| group = "io.lasteris.dev" | |
| version = "1.0.0-SNAPSHOT" | |
| repositories { | |
| mavenCentral() | |
| } | |
| val vertxVersion = "4.5.0" | |
| val junitJupiterVersion = "5.9.1" | |
| val jacksonVersion = "2.15.3" | |
| val mainVerticleName = "io.lasteris.dev.dev_workaround_backend.MainVerticle" | |
| val launcherClassName = "io.vertx.core.Launcher" | |
| val watchForChange = "src/**/*" | |
| val doOnChange = "${projectDir}/gradlew classes" | |
| application { | |
| mainClass.set(launcherClassName) | |
| } | |
| dependencies { | |
| implementation(platform("io.vertx:vertx-stack-depchain:$vertxVersion")) | |
| implementation("io.vertx:vertx-web") | |
| implementation("io.vertx:vertx-pg-client") | |
| implementation("io.vertx:vertx-web-client") | |
| implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") | |
| implementation("com.ongres.scram:client:2.1") | |
| implementation("ch.qos.logback:logback-core:1.4.11") | |
| implementation("org.slf4j:slf4j-api:2.0.9") | |
| implementation("ch.qos.logback:logback-classic:1.4.11") | |
| testImplementation("io.vertx:vertx-junit5") | |
| testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion") | |
| testImplementation("org.testcontainers:testcontainers:1.19.1") | |
| testImplementation ("io.vertx:vertx-unit") | |
| } | |
| java { | |
| toolchain { | |
| vendor.set(JvmVendorSpec.AMAZON) | |
| languageVersion.set(JavaLanguageVersion.of(21)) | |
| } | |
| } | |
| tasks.withType<ShadowJar> { | |
| archiveClassifier.set("fat") | |
| manifest { | |
| attributes(mapOf("Main-Verticle" to mainVerticleName)) | |
| } | |
| mergeServiceFiles() | |
| } | |
| tasks.withType<Test> { | |
| useJUnitPlatform() | |
| testLogging { | |
| events = setOf(PASSED, SKIPPED, FAILED) | |
| } | |
| } | |
| tasks.withType<JavaExec> { | |
| args = listOf("run", mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$launcherClassName", "--on-redeploy=$doOnChange") | |
| } |
This file contains hidden or 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
| <configuration> | |
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| <encoder> | |
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
| </encoder> | |
| </appender> | |
| <appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
| <file>/tmp/vertx.log</file> | |
| <append>true</append> | |
| <encoder> | |
| <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern> | |
| </encoder> | |
| </appender> | |
| <root level="debug"> | |
| <appender-ref ref="STDOUT" /> | |
| <appender-ref ref="FILE" /> | |
| </root> | |
| </configuration> |
This file contains hidden or 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
| package io.lasteris.dev.dev_workaround_backend; | |
| import io.netty.handler.logging.ByteBufFormat; | |
| import io.vertx.core.AbstractVerticle; | |
| import io.vertx.core.Promise; | |
| import io.vertx.core.http.HttpMethod; | |
| import io.vertx.core.http.HttpServer; | |
| import io.vertx.ext.web.Router; | |
| import io.vertx.ext.web.client.WebClient; | |
| import io.vertx.ext.web.client.WebClientOptions; | |
| import io.vertx.ext.web.handler.LoggerHandler; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import java.net.URLEncoder; | |
| import java.nio.charset.StandardCharsets; | |
| public class MainVerticle extends AbstractVerticle { | |
| private static final Logger Log = LoggerFactory.getLogger(MainVerticle.class); | |
| @Override | |
| public void start(Promise<Void> startPromise) { | |
| HttpServer server = vertx.createHttpServer(); | |
| Router router = Router.router(vertx); | |
| router.route("/*").handler(LoggerHandler.create()); | |
| router. | |
| route("/привет"). | |
| handler(ctx -> { | |
| Log.info(ctx.request().getParam("hi")); | |
| ctx.response().setStatusCode(202).end(); | |
| }); | |
| router.route(HttpMethod.GET,"/typo/").handler(ctx -> { | |
| Log.info(ctx.pathParam("hi")); | |
| WebClientOptions options = new WebClientOptions(); | |
| options.setLogActivity(true) | |
| .setActivityLogDataFormat(ByteBufFormat.HEX_DUMP); | |
| WebClient client = WebClient.create(vertx, options); | |
| client.get(8881, "127.0.0.1", /*URLEncoder.encode("/привет", StandardCharsets.UTF_8)*/"/привет") | |
| .addQueryParam("hi", "Привет") | |
| .send() | |
| .onComplete(e -> Log.info(String.valueOf(e.succeeded()))); | |
| ctx.response().setStatusCode(201).end(); | |
| }); | |
| server.requestHandler(router).listen(8881, http -> { | |
| if (http.succeeded()) { | |
| startPromise.complete(); | |
| Log.info("HTTP server started on port 8881"); | |
| } else { | |
| startPromise.fail(http.cause()); | |
| } | |
| }); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment