This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package examples | |
import scala.language.implicitConversions | |
sealed trait ExtractedValue[T] | |
class ArgExtractor[T](desired: Manifest[T]) { | |
def unapply[X](c: X)(implicit m: Manifest[X]): Option[T] = { | |
def sameArgs = desired.typeArguments.zip(m.typeArguments).forall { case (d, actual) => d >:> actual } | |
if (desired >:> m && sameArgs) Some(c.asInstanceOf[T]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add this method, and verb variants to ApiBuilder... | |
public static void get(String path, Function<Javalin, Handler> fn) { | |
staticInstance().get(prefixPath(path), fn.apply(staticInstance())); | |
} | |
// then you can remove the extra methods from ApiBuilder and Javalin which take the overloads |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twitter.finagle | |
import java.net.SocketAddress | |
import com.twitter.finagle.client.{StackClient, StdStackClient, Transporter} | |
import com.twitter.finagle.dispatch.{SerialClientDispatcher, SerialServerDispatcher} | |
import com.twitter.finagle.netty4.{Netty4Listener, Netty4Transporter} | |
import com.twitter.finagle.server.{Listener, StackServer, StdStackServer} | |
import com.twitter.finagle.transport.Transport | |
import io.netty.channel.ChannelPipeline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.http4k.metrics | |
import io.micrometer.core.instrument.Counter | |
import io.micrometer.core.instrument.MeterRegistry | |
import io.micrometer.core.instrument.Tags | |
import io.micrometer.core.instrument.Timer | |
import org.http4k.core.Filter | |
import org.http4k.core.Request | |
import org.http4k.filter.ResponseFilters.ReportLatency | |
import java.time.Clock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
annotations: | |
nginx.ingress.kubernetes.io/proxy-body-size: "0" | |
nginx.ingress.kubernetes.io/proxy-read-timeout: "600" | |
nginx.ingress.kubernetes.io/proxy-send-timeout: "600" | |
name: docker-registry | |
spec: | |
backend: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
data class ValidatedNumber(val value: Long) { | |
init { | |
if (value < 0 || value > 100) throw IllegalArgumentException("Out of range") | |
} | |
} | |
val lens = Query.long().map(::ValidatedNumber).required("myLong") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.http4k.core.HttpHandler | |
import org.http4k.core.Method | |
import org.http4k.core.Request | |
import org.http4k.core.Response | |
import org.http4k.core.Status | |
import org.http4k.core.Uri | |
import org.http4k.core.then | |
import org.http4k.events.AutoJsonEvents | |
import org.http4k.events.Event | |
import org.http4k.events.EventFilters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.http4k.core.Body | |
import org.http4k.core.Method | |
import org.http4k.core.Request | |
import org.http4k.core.Response | |
import org.http4k.core.Status | |
import org.http4k.core.then | |
import org.http4k.filter.DebuggingFilters | |
import org.http4k.filter.ServerFilters | |
import org.http4k.format.Jackson.auto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyGreatFlags(args: Array<String>) : Bunting(args) { | |
val user by requiredFlag() | |
val password by requiredFlag() | |
val version by defaultedFlag("0.0.0") | |
} | |
// run the main with: java (...) Mainkt --user foo --password bar | |
fun main(args: Array<String>) = MyGreatFlags(args).use { | |
println(user) // foo | |
println(password) // bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am daviddenton on github. | |
* I am daviddenton (https://keybase.io/daviddenton) on keybase. | |
* I have a public key ASBCXxFMUhDpkU0nuStiO7UXK879HTLE5CitEDuRXB9oyQo | |
To claim this, I am signing this object: |
OlderNewer