dave
10/30/2017, 1:52 PMdave
11/14/2017, 10:12 AMg4sarma
01/15/2018, 4:39 PMdave
01/15/2018, 8:54 PMdave
02/23/2018, 3:05 PMfun add(value1: Int, value2: Int): HttpHandler = {
Response(OK).with(
Body.string(TEXT_PLAIN).toLens() of (value1 + value2).toString()
)}
val contract = contract(OpenApi(ApiInfo("my great api", "v1.0"), Argo),
"/add" / <http://Path.int|Path.int>().of("value1") / Path.fixed("hello") / <http://Path.int|Path.int>().of("value2") meta {
summary = "add"
description = "Adds 2 numbers together"
returning("The result" to OK)
} bindContract GET
to { a, _, c -> add(a, c) }
)
contract.asServer(Jetty(8000)).start()
dave
02/24/2018, 8:13 AMscap
02/27/2018, 4:46 AMelifarley
03/02/2018, 1:54 PMelifarley
03/06/2018, 9:46 PMclass SimpleObject(val id: String, val attrs: Map<String, Any?>,
val created: ZonedDateTime,
val updated: ZonedDateTime
)
If I use with( Header.zonedDateTime().required("last-modified") of obj.created)
, I end up with multiple attributes like "created":{"dateTime":{"date":{"year":2018,"month":3,...
).
I think it should be a single String attribute, based on my understanding of this.map(ZonedDateTime::parse, DateTimeFormatter.ISO_ZONED_DATE_TIME::format)
in file lensSpec.ktelifarley
03/07/2018, 6:16 PM"object-1161328054": {
"type": "object",
"properties": {}
},
"object158819726": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"attrs": {
"$ref": "#/definitions/object-1161328054"
},
"created": {
"type": "string"
},
"updated": {
"type": "string"
}
}
},
"object-1161328054": {
"type": "object",
"properties": {}
},
dave
03/09/2018, 6:51 AMelifarley
03/09/2018, 10:37 AMHTTP/1.1 400 body 'body' must be object
This message is hiding an exception. How can I get hold of it?
I have these filters:
routes(
"/sgzr/api/v1" bind Api.router(productService, orderService)
).let {
DebuggingFilters.PrintRequestAndResponse()
.then(ServerFilters.Cors(CorsPolicy.UnsafeGlobalPermissive))
.then(ServerFilters.CatchAll())
.then(ServerFilters.CatchLensFailure)
.then(it)
}
dave
03/20/2018, 9:58 PMdave
03/28/2018, 4:35 PMdave
04/06/2018, 7:30 PMCatchLensFailure
to create a custom response. New method looks like this: ServerFilters.CatchLensFailure { lensFailure -> Response(OK).body(lensFailure.localizedMessage) }
. Releasing in 3.23.0joscha.alisch
04/10/2018, 5:50 PMimport org.http4k.contract.*
import org.http4k.core.*
import org.http4k.format.Jackson
import org.http4k.format.Jackson.auto
import org.http4k.routing.bind
import org.http4k.routing.routes
import org.http4k.server.Jetty
import org.http4k.server.asServer
data class MyDataClass(val something: String)
val requestBody = Body.auto<MyDataClass>().toLens()
fun main(args: Array<String>) {
routes(
"/api" bind contract(OpenApi(ApiInfo("My great API", "v1.0"), Jackson),"/route" meta {
body = requestBody
} bindContract Method.GET to ::handler)
).asServer(Jetty(5000)).start()
}
fun handler(request: Request): Response {
return Response(Status.OK)
}
gives me {
“swagger” : “2.0",
“info” : {
“title” : “My great API”,
“version” : “v1.0”,
“description” : “”
},
“basePath” : “/”,
“tags” : [ ],
“paths” : {
“/api/route” : {
“get” : {
“tags” : [ “/api” ],
“summary” : “<unknown>“,
“description” : null,
“produces” : [ ],
“consumes” : [ “application/json” ],
“parameters” : [ {
“in” : “body”,
“name” : “body”,
“description” : null,
“required” : true,
“type” : “object”
} ],
“responses” : { },
“supportedContentTypes” : [ ],
“security” : [ ]
}
}
},
“securityDefinitions” : { },
“definitions” : { }
}
RichyHBM
04/25/2018, 6:28 PMdave
04/25/2018, 7:46 PMdave
06/15/2018, 7:53 AMdave
06/20/2018, 9:16 AMandyD
06/20/2018, 9:55 PMRichyHBM
06/21/2018, 7:58 PMs4nchez
06/25/2018, 8:47 AM/foo/{bar:.*}
(the .
is important ;))dave
07/11/2018, 10:35 AMnapperley
07/23/2018, 11:07 PMdave
08/15/2018, 9:09 PMdave
08/21/2018, 1:12 PMAlbert
09/10/2018, 6:01 PMDavid Hamilton
09/11/2018, 10:33 AMdave
10/03/2018, 6:10 PMdave
10/03/2018, 6:10 PMXavier Hanin
10/04/2018, 10:18 AM