Skip to content
Snippets Groups Projects
Commit d8a85cff authored by Marty Pitt's avatar Marty Pitt
Browse files

feat(http): added WebsocketOperation for saved websocket queries

parent 44e1eae3
No related branches found
No related tags found
No related merge requests found
Pipeline #1262632062 passed
......@@ -28,6 +28,11 @@ data class HttpService(val baseUrl: String) : AnnotationProvider {
url : String
}
annotation WebsocketOperation {
path : String
}
annotation HttpHeader {
name : String
[[ Pass a value when using as an annotation on an operation.
......@@ -105,6 +110,29 @@ data class HttpOperation(val method: String, val url: String) : AnnotationProvid
override fun toAnnotation(): Annotation = Annotation(NAME, mapOf("method" to method, "url" to url))
}
data class WebsocketOperation(val path: String) : AnnotationProvider {
companion object {
const val NAME = "taxi.http.WebsocketOperation"
fun fromAnnotation(annotation: Annotation): WebsocketOperation {
// TODO : We should just define the bloody annotation in taxi. Then this would be handled
// at the compiler level!!!
val parameters = annotation.parameters
require(parameters.containsKey("path")) { "@WebsocketOperation requires a path parameter" }
return WebsocketOperation(parameters["path"]!!.toString())
}
fun fromQuery(query: TaxiQlQuery): WebsocketOperation? {
val httpAnnotation = query.annotations.singleOrNull { annotation -> annotation.name == WebsocketOperation.NAME }
return if (httpAnnotation != null) {
fromAnnotation(httpAnnotation)
} else null
}
}
override fun toAnnotation(): Annotation = Annotation(NAME, mapOf("path" to path))
}
object HttpRequestBody : AnnotationProvider {
override fun toAnnotation(): Annotation {
return Annotation(NAME)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment