Questions tagged [http4s]

Http4s is a minimal, idiomatic Scala interface for HTTP services.

http4s is a typeful, purely functional HTTP library for client and server applications written in Scala.

Principles

Typeful: http4s uses Scala’s type system to increase self-documentation and compile-time verification. Standard headers are lazily parsed to semantically meaningful types, and typeclasses are provided to encode and decode bodies to several common formats.

Purely functional: The pure functional side of Scala is favored to promote composability and easy reasoning about your code. The core is built on an immutable case class model of HTTP requests and responses, shared by the client and the server.

Asynchronous: Much of the API is built around a scalaz.concurrent.Task. Bodies are modeled as scalaz-streams for performant chunking of large messages in constant memory.

Modular: http4s has a lightweight core with multiple deployment options. Server applications can be deployed to blaze, the native platform, or as a servlet application. Client applications run on either blaze or an async-http-client backend. Several libraries useful in everyday HTTP programming, such as circe and argonaut, are integrated via optional modules.

Community-oriented: http4s is a community-driven project, and aims to provide a welcoming environment for all users. We are proud to be a Typelevel incubator project.

Official website: http://http4s.org/

161 questions
0
votes
1 answer

Tapir seperate static file endpoint description and server logic

I need to serve a small set of static files using tapir with http4s as the implementation. All endpoint definitions are in their own files and exposed using swagger. The documentation has lots of good examples on serving static files, but without…
jen
  • 357
  • 2
  • 10
0
votes
0 answers

What is the difference between Ember and Blaze server/client implementations?

I could not find any information on what http4s server/client implementation to choose, Ember or Blaze What is better and why. What are the key differences between them? Maybe someone from the creators of the http4s could answer this.
slovvic
  • 417
  • 3
  • 6
  • 14
0
votes
0 answers

http4s Router default return method not allowed

org.http4s.server.Router has a .orNotFound, but instead of this I want to return 405 methodNotAllowed. How can I do that? Please provide example. I saw the .orElse but not sure how to use it. Router( "/api" -> myroutes() ).orElse(.??.) Thanks
saad
  • 371
  • 3
  • 13
0
votes
1 answer

Decode a list of IO[Int] in http4s when returning value in response

I am currently trying to write extension for external API using http4s Client and Server tools. My idea was: when endpoint, which I created using Server is triggered, make multiple requests (to same endpoint on external API, but with different…
0
votes
1 answer

Pac4j(http4s-pac4j): SecurityFilterMiddleware: Fallbacking to AnonymousProfile using OIDC?

I have questions about OidcClient and AnonymousClient. Can we use SecurityFilterMiddleware to configure endpoints like the following? Create a Profile based on that information if already logged in with OIDC If not, create an AnonymousProfile…
Windymelt
  • 139
  • 8
0
votes
0 answers

Fix Auth middleware for http4s 0.16

I've following code in http4s 0.8.6 and I'm trying to upgrade it to http4s 0.16.6. package clear.service import clear.api.intf.Scope import clear.api.impl._ import clear.dao.AbstractTokenFactory import org.http4s._ import…
Sujit Baniya
  • 895
  • 9
  • 27
0
votes
1 answer

How to combine two HttpService in http4s 0.15.16

I have a legacy product that's using http4s 0.8 version. I'm trying to do an incremental upgrade and the best version I could upgrade is 0.15.16. Currently I could use following syntax service1 orElse service2 orElse But in 0.15.16 orElse is not…
Sujit Baniya
  • 43
  • 1
  • 5
0
votes
1 answer

Why is Either expected in the following for comprehension?

I am playing with tagless final in scala. I use pureconfig to load the configuration and then use the configuration values to set the server port and host. Snippet def create[F[_]: Async] = for { config <-…
nashter
  • 1,181
  • 1
  • 15
  • 33
0
votes
2 answers

How better organize tapir endpoints?

I am developing a scala web application with http4s and use tapir for endpoints. I am new in it, and now I am looking for a better way to organize my project. Now I have different classes with endpoints description and server logic in one. They have…
Post Cat
  • 1
  • 1
0
votes
1 answer

How to write idiomatic scala code for http4s

I'm struggling a bit with how to translate an imperative style to a functional style. In a imperative web request I'm used to saying something like the following psudo code: public Response controllerAction(Request request) { val (req,…
WhiteleyJ
  • 1,393
  • 1
  • 22
  • 29
0
votes
0 answers

Get a Stream of Entity from an Http4s Response with Circe

I'm trying to retrieve a Stream[IO, Job] from an http4s Response, but the Scala compiler warns me that it cannot find any suitable Decoder: Cannot decode into a value of type fs2.Stream[IO,Job], because no EntityDecoder[[+A]IO[A],…
riccardo.cardin
  • 7,971
  • 5
  • 57
  • 106
0
votes
2 answers

HTTP4s increase max upload size

I am toying with http4s multipart file upload, which I got working. However, the multipart parsing throws an exception for file uploads bigger than ~500kb. The error on client side, which is thrown while parsing multipart body is HTTP 422: The…
Yogesh
  • 78
  • 6
0
votes
1 answer

BlazeServerBuilder asking for extra parameter

I'm trying to write a simple http server in scala with http4. But when I follow tutorials to create a BlazeServer builder, it will say that I need to supply a Timer[IO] (gives me the error Unspecified value parameters: timer: Timer[IO]), which I…
joseph G
  • 3
  • 1
0
votes
1 answer

How to integrate Prometheus Metrics Middleware with http4s DSL service

To analyze the performance issues with our ember-server, Trying to get the server metrics on prometheus using the document mentioned here: https://http4s.org/v0.23/middleware/ build.sbt "org.http4s" %% "http4s-ember-server" %…
0
votes
1 answer

Ajax POST request with Array[Byte] response

I'm receiving an ajax POST request and need to process the body data as a ByteBuffer and respond with an Array[Byte] using Http4s (0.23.7). This is as far I have been able to put things together, although it's not working yet: // http4s/fs2/cats…
Marc Grue
  • 5,865
  • 3
  • 16
  • 23