Skip to content

Commit

Permalink
http (feature): Add interface for Scala Native
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Nov 13, 2024
1 parent 3724030 commit 099b9ec
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package wvlet.airframe.http

import wvlet.airframe.http.client.HttpClientBackend

import scala.concurrent.ExecutionContext

/**
* Scala Native specific implementation
*/
private object Compat extends CompatApi {
override def urlEncode(s: String): String = ???
override def defaultHttpClientBackend: HttpClientBackend = ???

override def defaultExecutionContext: ExecutionContext = ???
override def defaultHttpClientLoggerFactory: HttpLoggerConfig => HttpLogger = ???
override def currentRPCContext: RPCContext = ???
override def attachRPCContext(context: RPCContext): RPCContext = ???
override def detachRPCContext(previous: RPCContext): Unit = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import scala.concurrent.ExecutionContext
private[http] trait CompatApi {
def urlEncode(s: String): String

def hostServerAddress: ServerAddress
def hostServerAddress: ServerAddress = ServerAddress.empty
def defaultHttpClientBackend: HttpClientBackend
def defaultExecutionContext: ExecutionContext
def defaultHttpClientLoggerFactory: HttpLoggerConfig => HttpLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import scala.concurrent.TimeoutException

object HttpClientFilterTest extends AirSpec {

if (isScalaNative) {
pending(s"Http client is not supported in Scala Native yet")
}

private def newDummyClient(config: HttpClientConfig, f: PartialFunction[Request, Response]): AsyncClient =
new AsyncClientImpl(new DummyHttpChannel(f), config)

Expand Down
8 changes: 6 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ lazy val nativeProjects: Seq[ProjectReference] = Seq(
ulid.native,
rx.native,
control.native,
codec.native
codec.native,
http.native
)

// Integration test projects
Expand Down Expand Up @@ -767,7 +768,7 @@ lazy val rx =
.dependsOn(log)

lazy val http =
crossProject(JVMPlatform, JSPlatform)
crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.enablePlugins(BuildInfoPlugin)
.in(file("airframe-http"))
Expand Down Expand Up @@ -797,6 +798,9 @@ lazy val http =
"org.scala-js" %%% "scalajs-dom" % SCALAJS_DOM_VERSION
)
)
.nativeSettings(
nativeBuildSettings
)
.dependsOn(rx, control, surface, json, codec, di)

lazy val httpCodeGen =
Expand Down

0 comments on commit 099b9ec

Please sign in to comment.