All Projects → mirego → trikot.http

mirego / trikot.http

Licence: BSD-3-Clause license
HTTP networking abstraction for Kotlin Multiplatform

Programming Languages

kotlin
9241 projects
swift
15916 projects
groovy
2714 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to trikot.http

trikot.patron
Kotlin Multiplatform Sample Project using Trikot libraries
Stars: ✭ 13 (-13.33%)
Mutual labels:  kotlin-multiplatform, trikot
trikot.foundation
Core utilities for Kotlin Multiplatform
Stars: ✭ 21 (+40%)
Mutual labels:  kotlin-multiplatform, trikot
island-time
A Kotlin Multiplatform library for working with dates and times
Stars: ✭ 69 (+360%)
Mutual labels:  kotlin-multiplatform
Dads
*BA DUM TSSS*
Stars: ✭ 240 (+1500%)
Mutual labels:  kotlin-multiplatform
kgql
GraphQL Document wrapper generator for Kotlin Multiplatform Project and Android
Stars: ✭ 54 (+260%)
Mutual labels:  kotlin-multiplatform
moko-network
Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 107 (+613.33%)
Mutual labels:  kotlin-multiplatform
kmpapp
👨‍💻 Kotlin Mobile Multiplatform App (Android & iOS). One Code To Rule Them All. MVVM, DI (Kodein), coroutines, livedata, ktor, serialization, mockk, detekt, ktlint, jacoco
Stars: ✭ 34 (+126.67%)
Mutual labels:  kotlin-multiplatform
devtools-library
Multiplatform, pluggable, extensible, and dynamic config library which supports YAML and JSON as a source.
Stars: ✭ 15 (+0%)
Mutual labels:  kotlin-multiplatform
kotlin-multiplatform-libsodium
A kotlin multiplatform wrapper for libsodium, using directly built libsodium for jvm and native, and libsodium.js for js targets.
Stars: ✭ 38 (+153.33%)
Mutual labels:  kotlin-multiplatform
moko-web3
Ethereum Web3 implementation for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 32 (+113.33%)
Mutual labels:  kotlin-multiplatform
KmLogging
Kotlin multiplatform logging. High performance, composable and simple to use.
Stars: ✭ 21 (+40%)
Mutual labels:  kotlin-multiplatform
kgl
Lightweight OpenGL abstraction for Kotlin Multiplatform
Stars: ✭ 21 (+40%)
Mutual labels:  kotlin-multiplatform
tv-maniac
Tv-Maniac is a Multiplatform app (Android & iOS) for viewing TV Shows from TMDB.
Stars: ✭ 55 (+266.67%)
Mutual labels:  kotlin-multiplatform
sweekt
🍭 Some sugar to sweeten Kotlin development.
Stars: ✭ 35 (+133.33%)
Mutual labels:  kotlin-multiplatform
kmp mobile template
Template for the development of native iOS and Android apps with shared business-logic using KMP, Redux architecture and XcodeGen.
Stars: ✭ 21 (+40%)
Mutual labels:  kotlin-multiplatform
libs.kmp.icerock.dev
Kotlin Multiplatform libraries list with info auto-fetch
Stars: ✭ 178 (+1086.67%)
Mutual labels:  kotlin-multiplatform
Notflix
Kotlin Multiplatform playground
Stars: ✭ 272 (+1713.33%)
Mutual labels:  kotlin-multiplatform
moko-maps
Control your map from common code for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 47 (+213.33%)
Mutual labels:  kotlin-multiplatform
moko-graphics
Graphics primitives for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 11 (-26.67%)
Mutual labels:  kotlin-multiplatform
PopKorn
DI can be simple. Forget about modules and components. Just use it!
Stars: ✭ 139 (+826.67%)
Mutual labels:  kotlin-multiplatform

⚠️ Warning: this project as been moved

See the new trikot repository for releases starting from 3.0.0.

Trikot.http

Incubating

Kotlin Multiplaform http networking abstraction.

  • Default Http request implementation for each platform
  • Http header management and Error management
  • Connectivity (Reachability) management
  • Deserialization of results using kotlinx.serialization
  • Abstract network in Kotlin Multiplatform making sure every bit of network code is testable.
  • Implement Reactive Streams pattern

RequestBuilder

Request builder is a simple class that provides information about the request to send. See RequestBuilder.kt for fields documentation.

HttpRequestPublisher

To send http requests

  • Create a child class of HttpRequestPublisher
  • Provide a RequestBuilder by overriding builder var
  • Override processResponse to transform HttpResponse into expected result type.
val request = object: HttpRequestPublisher<String>() {
    override val builder = RequestBuilder().also {
        it.baseUrl = "http://www.site.com/path/to/request"
    }

    override fun processResponse(response: HttpResponse): String = response.bodyString ?: ""
}
request.execute()

DeserializableHttpRequestPublisher

To deserialize a JSON payload:

  • Create a kotlix.serializable class
  • Create a DeserializableHttpRequestPublisher with the serializer in parameter.

NoResponseHttpRequestPublisher

If there is no need to parse the body of the response, use this publisher instead. Only errors will be handled.

ResponseHttpRequestPublisher

If you want the raw HttpResponse object, use this publisher.

@Serializable
data class Foo(val bar: String)

val request = DeserializableHttpRequestPublisher<Foo>(
    Foo.serializer,
    RequestBuilder().also { it.path = "/getFoo" }
)
request.execute()

HeaderProvider

HttpRequestPublisher and DeserializableHttpRequestPublisher both haves an optional httpHeaderProvider constructor parameter to provide additionnal request header (Authorization token per example). See HttpHeaderProvider.kt for complete documentation.

ConnectivityPublisher

When swift-extensions or android-ktx are configured (See below), you can access the ConnectivityState using the following sample:

HttpConfiguration.connectibityPublisher.subscribe(cancelableManager) {
    if it == NONE {
        print("No connection")
    } else {
        print("We have connection")
    }
}

Values are WIFI, CELLULAR, NONE

Installation

Import dependencies
    api "com.mirego.trikot:http:$trikot_http_version"
    jvm "com.mirego.trikot:http-jvm:$trikot_http_version"
    js "com.mirego.trikot:http-js:$trikot_http_version"
    iosx64 "com.mirego.trikot:http-iosx64:$trikot_http_version"
    iosarm64 "com.mirego.trikot:http-iosarm64:$trikot_http_version"
Setup platforms

License

Trikot.http is © 2018-2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].