Skip to content

Commit 3b6165b

Browse files
committed
docs: completed Endpoint code documentation
1 parent 0b1c201 commit 3b6165b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • lib/src/main/kotlin/com/openmeteo/api/common/http

lib/src/main/kotlin/com/openmeteo/api/common/http/Endpoint.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import java.io.InputStream
1212
import java.net.URL
1313
import javax.net.ssl.HttpsURLConnection
1414

15+
/**
16+
* An API endpoint with a context [URL] which can automatically parse response
17+
* data of a GET request with a [Query]
18+
*/
1519
class Endpoint(
1620
@Transient
1721
val context: URL,
@@ -51,6 +55,11 @@ class Endpoint(
5155
}
5256
}
5357

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+
*/
5463
inline fun <reified T> query(query: Query) =
5564
runCatching { query.toURL(context) }
5665
.mapCatching { get(it) }

0 commit comments

Comments
 (0)