mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 11:06:49 +00:00
feature/Add http4s-jar profile to pom.xml and update scala-maven-plugin configuration; refactor withCallContext to use OptionT in Http4s700.scala
This commit is contained in:
parent
4df0cc9100
commit
21f6314e4d
@ -23,6 +23,39 @@
|
||||
<webXmlPath>src/main/resources/web.xml</webXmlPath>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>http4s-jar</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<finalName>${project.artifactId}-http4s</finalName>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>bootstrap.http4s.Http4sServer</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>http4s-fat-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
@ -612,6 +645,20 @@
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
<jvmArgs>
|
||||
<jvmArg>-Xms4G</jvmArg>
|
||||
<jvmArg>-Xmx12G</jvmArg>
|
||||
<jvmArg>-XX:MaxMetaspaceSize=4G</jvmArg>
|
||||
<jvmArg>-XX:+UseG1GC</jvmArg>
|
||||
</jvmArgs>
|
||||
<args>
|
||||
<arg>-deprecation</arg>
|
||||
<arg>-feature</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package code.api.v7_0_0
|
||||
|
||||
import cats.data.Kleisli
|
||||
import cats.data.{Kleisli, OptionT}
|
||||
import cats.effect._
|
||||
import cats.implicits._
|
||||
import code.api.util.{APIUtil, CustomJsonFormats}
|
||||
@ -19,6 +19,8 @@ import scala.language.{higherKinds, implicitConversions}
|
||||
|
||||
object Http4s700 {
|
||||
|
||||
type HttpF[A] = OptionT[IO, A]
|
||||
|
||||
implicit val formats: Formats = CustomJsonFormats.formats
|
||||
implicit def convertAnyToJsonString(any: Any): String = prettyRender(Extraction.decompose(any))
|
||||
|
||||
@ -31,12 +33,13 @@ object Http4s700 {
|
||||
|
||||
object CallContextMiddleware {
|
||||
|
||||
def withCallContext(routes: HttpRoutes[IO]): HttpRoutes[IO] = Kleisli { req: Request[IO] =>
|
||||
val callContext = CallContext(userId = "example-user", requestId = java.util.UUID.randomUUID().toString)
|
||||
val updatedAttributes = req.attributes.insert(callContextKey, callContext)
|
||||
val updatedReq = req.withAttributes(updatedAttributes)
|
||||
routes(updatedReq)
|
||||
}
|
||||
def withCallContext(routes: HttpRoutes[IO]): HttpRoutes[IO] =
|
||||
Kleisli[HttpF, Request[IO], Response[IO]] { req: Request[IO] =>
|
||||
val callContext = CallContext(userId = "example-user", requestId = java.util.UUID.randomUUID().toString)
|
||||
val updatedAttributes = req.attributes.insert(callContextKey, callContext)
|
||||
val updatedReq = req.withAttributes(updatedAttributes)
|
||||
routes(updatedReq)
|
||||
}
|
||||
}
|
||||
|
||||
val v700Services: HttpRoutes[IO] = HttpRoutes.of[IO] {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user