-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify http cache per platform (#1072)
* Specify http cache per platform * Match top level naming * Add missing trailing comma before closing bracket * Include okio dependency * Fix dependency target --------- Co-authored-by: Ashley Davies <[email protected]>
- Loading branch information
Showing
22 changed files
with
154 additions
and
107 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
16 changes: 16 additions & 0 deletions
16
cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/GoogleApiException.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.ashdavies.cloud | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
internal data class GoogleApiException( | ||
val error: Error, | ||
) : Exception(error.message) { | ||
|
||
@Serializable | ||
data class Error( | ||
val code: Int, | ||
val message: String, | ||
val status: String, | ||
) | ||
} |
This file contains 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
30 changes: 0 additions & 30 deletions
30
cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Validator.kt
This file was deleted.
Oops, something went wrong.
This file contains 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
11 changes: 11 additions & 0 deletions
11
http-client/src/commonMain/kotlin/io/ashdavies/http/CallValidator.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.ashdavies.http | ||
|
||
import io.ktor.client.call.body | ||
import io.ktor.client.plugins.ClientRequestException | ||
import io.ktor.client.plugins.HttpCallValidator | ||
|
||
public inline fun <reified T : Exception> HttpCallValidator.Config.throwClientRequestExceptionAs() { | ||
handleResponseExceptionWithRequest { exception, _ -> | ||
if (exception is ClientRequestException) throw exception.response.body<T>() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
http-client/src/commonMain/kotlin/io/ashdavies/http/HttpCache.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.ashdavies.http | ||
|
||
import io.ktor.client.plugins.cache.HttpCache | ||
import io.ktor.client.plugins.cache.storage.FileStorage | ||
import okio.Path | ||
|
||
public fun HttpCache.Config.publicStorage(path: Path) { | ||
publicStorage(FileStorage(path.toFile())) | ||
} |
Oops, something went wrong.