Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http (feature): Add interface for Scala Native #3724

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading