Skip to content

Cross Server and ember server to JS in 0.23#5663

Merged
rossabaker merged 4 commits intohttp4s:series/0.23from
armanbilge:topic/0.23-server-js-part2
Dec 6, 2021
Merged

Cross Server and ember server to JS in 0.23#5663
rossabaker merged 4 commits intohttp4s:series/0.23from
armanbilge:topic/0.23-server-js-part2

Conversation

@armanbilge
Copy link
Copy Markdown
Member

@armanbilge armanbilge commented Dec 5, 2021

Here we are again :)

Merging this will fully synchronize 0.23 and main regarding JS crosses. This is valuable e.g. for #5657 since it's very difficult to anticipate a crossed-main from an uncrossed 0.23.

It's not elegant, but I finally figured out how to work around the InetSocketAddress issue: Server is (unfortunately) split/duplicated across JVM and JS, and a http4s-private Ip4sServer provides a cross-platform way to implement Server without touching InetSocketAddress and using only ip4s stuff. This allows us to cross ember-server.

Comment on lines 57 to 69
)
val Host = InetAddress.getLoopbackAddress.getHostAddress
def Host = InetAddress.getLoopbackAddress.getHostAddress
val HttpPort = 8080

val IPv4SocketAddress: InetSocketAddress =
def IPv4SocketAddress: InetSocketAddress =
InetSocketAddress.createUnresolved(IPv4Host, HttpPort)
val IPv6SocketAddress: InetSocketAddress =
def IPv6SocketAddress: InetSocketAddress =
InetSocketAddress.createUnresolved(IPv6Host, HttpPort)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make these defs so that the Scala.js linker can elide them. It's not ideal of course, but the alternative is splitting files. Reasonable compromise?

@rossabaker rossabaker merged commit 7f7f37d into http4s:series/0.23 Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants