All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.core.extensions.kt Maven / Gradle / Ivy

There is a newer version: 5.31.0.0
Show newest version
package org.http4k.core

@Suppress("UNCHECKED_CAST")
fun  T.alphabetiseHeaders(): T = headers
    .groupBy { it.first }
    .toSortedMap()
    .mapValues { it to it.value.sortedBy { it.second } }
    .asSequence()
    .fold(this) { acc, toRemove ->
        toRemove.value.second.fold(acc.removeHeader(toRemove.key) as T) { t, toAdd ->
            t.header(toAdd.first, toAdd.second) as T
        }
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy