Questions tagged [http4k]

http4k is an HTTP toolkit written in Kotlin that enables the serving and consuming of HTTP services in a functional and consistent way.

http4k applications are just Kotlin functions which can be mounted into a running backend.

The principles of http4k are:

  • Application as a Function: Based on the Twitter paper "Your Server as a Function", all HTTP services can be composed of 2 types of simple function: HttpHandler, Filter
  • Immutability: All entities in the library are immutable unless their function explicitly disallows this.
  • Symmetric: The HttpHandler interface is identical for both HTTP services and clients. This allows for simple offline testability of applications, as well as plugging together of services without HTTP container being required.
  • Dependency-lite: Apart the from Kotlin StdLib, http4k-core module has ZERO dependencies and weighs in at ~700kb. Add-on modules only have dependencies required for specific implementation.
  • Testability Built by TDD enthusiasts, so supports super-easy mechanisms for testing.
  • Modularity: Common behaviours are abstracted into the http4k-core module, but there are several pluggable modules for different purposes.

Project website: https://www.http4k.org/

Github Project Organization: https://github.com/http4k

23 questions
0
votes
1 answer

Getting ID token from google sign-in

I am trying to use http4k's built in oauth module to implement Google sign-in in my backend app. Here is what I have so far: val googleClientId = "" val googleClientSecret = "" // this is a test implementation of…
Arnab Datta
  • 5,356
  • 10
  • 41
  • 67
0
votes
0 answers

Is it possible to use Http4k to upload to an Amazon S3 bucket with a presigned-url?

I'm currently using an AWS recommended method of uploading to an S3 bucket using a presigned url that is detailed here // Create the connection and use it to upload the new object using the pre-signed URL. HttpURLConnection connection =…
mooglin
  • 500
  • 5
  • 17
0
votes
1 answer

http4k routes documentation

I have an old kotlin application that uses http4k for rest endpoints. Application is huge and there are several modules that run independently. These modules expose routes and nested routes. As a person who is managing this application, I want to…
Rohit Sachan
  • 1,178
  • 1
  • 8
  • 16
0
votes
0 answers

Kotlin http4k read response as JSONObject (org.json)

As a beginner to kotlin and http4k, I am trying to read json response of a build job in jenkins. The sample code I have is as follows val request = Request(Method.GET, "https://myjenkins.com/api/json") .header("Authorization", "Basic…
g0c00l.g33k
  • 2,458
  • 2
  • 31
  • 41
0
votes
1 answer

Initialize class with higher order functions in kotlin

Higher Order Functions in Kotlin: I have a class that takes wto higher order functions: data class Data(id: String) class MyClass( private val getData: (find1: (String) -> Data?, find2: (String) -> Data?) -> (Request) -> Either
Avenger
  • 793
  • 11
  • 31
0
votes
2 answers

Why Kotlin type inference does not work for functional interface?

I'm working on a http4k web app. Http4k has a nice functional scheme for http handlers and filters (aka interceptors). typealias HttpHandler = (Request) -> Response interface Filter : (HttpHandler) -> HttpHandler {...} I wanted to write a simple…
Jen
  • 1,206
  • 9
  • 30
0
votes
1 answer

What is the difference between throttling and load balancing?

I am trying to make a REST API with Kotlin/http4k and one of the specs is that it should implement throttling. Are there any differences between throttling and load balancing?
Cosmin_Victor
  • 154
  • 1
  • 13
0
votes
1 answer

How can websocket broadcast be implemented with http4k?

I'm building a small websocket app with http4k websocket and looks like there is no documentation about how to implement message broadcasting with it (i.e. react to a message sending it to all the clients except the one that sent the message). Is it…
Talysson
  • 1,363
  • 1
  • 9
  • 13
1
2