We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Endpoint
1 parent 0b1c201 commit 3b6165bCopy full SHA for 3b6165b
1 file changed
lib/src/main/kotlin/com/openmeteo/api/common/http/Endpoint.kt
@@ -12,6 +12,10 @@ import java.io.InputStream
12
import java.net.URL
13
import javax.net.ssl.HttpsURLConnection
14
15
+/**
16
+ * An API endpoint with a context [URL] which can automatically parse response
17
+ * data of a GET request with a [Query]
18
+ */
19
class Endpoint(
20
@Transient
21
val context: URL,
@@ -51,6 +55,11 @@ class Endpoint(
51
55
}
52
56
53
57
58
+ /**
59
+ * GET, with a [Query], the endpoint context url and parse the response data
60
+ * (from the specified query format or, if not a [QueryContentFormat], from
61
+ * json) as the reified generic type
62
54
63
inline fun <reified T> query(query: Query) =
64
runCatching { query.toURL(context) }
65
.mapCatching { get(it) }
0 commit comments