Skip to content

Sharaf http4s native#74

Merged
sake92 merged 7 commits into
mainfrom
sharaf-http4s-native
Apr 13, 2026
Merged

Sharaf http4s native#74
sake92 merged 7 commits into
mainfrom
sharaf-http4s-native

Conversation

@sake92

@sake92 sake92 commented Apr 11, 2026

Copy link
Copy Markdown
Owner

Replaces #73

@lolgab Can you test it locally please?
IDK if my fix is correct, I was getting error about fs2.io.readOutputStream.

This is how I tested it:

deder exec -t publishLocal

and then created hello-http4s-native.scala

//> using scala 3.7.4
//> using platform native
//> using nativeVersion 0.5.9
//> using dep ba.sake::sharaf-http4s::0.17.1-SNAPSHOT
//> using dep org.http4s::http4s-ember-server::0.23.34
//> using repository m2Local

import cats.effect.*
import com.comcast.ip4s.*
import org.http4s.ember.server.*
import ba.sake.sharaf.*
import ba.sake.sharaf.http4s.*

val routes = Routes:
  case GET -> Path("hello", name) =>
    Response.withBody(s"Hello $name")
  case GET -> _ =>
    Response.withBody("Go to http://localhost:8181/hello/your-name")

object Main extends IOApp.Simple:
  def run =
    EmberServerBuilder
      .default[cats.effect.IO]
      .withHost(ipv4"0.0.0.0")
      .withPort(port"8181")
      .withHttpApp(SharafHttpApp(SharafHandler.routes(routes)))
      .build
      .useForever
scala --power package hello-http4s-native.scala -o http4s
./http4s

@lolgab

lolgab commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

It works for me!
The solution with fs2.io.readOutputStream is more efficient but it's having problems on Scala Native.
We can reconsider using it when typelevel/fs2#3714 is merged.

@sake92 sake92 merged commit 7701b97 into main Apr 13, 2026
3 of 4 checks passed
@sake92 sake92 deleted the sharaf-http4s-native branch April 13, 2026 11:21
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.

2 participants