Ktorfit
Ktorfit copied to clipboard
Set the Headers value as vararg
Is your feature request related to a problem? Please describe.
Not a real problem, however in Retrofit it's possible to call Headers like this (with a single value):
@Headers("Accept: application/json")
@GET
fun example(): Call<Example>
In Ktorfit an Array is required:
@Headers(["Accept: application/json"])
@GET
fun example(): Call<Example>
Describe the solution you'd like
It's not much of a deal, but if the Headers value would be a vararg, it could be used like in Retrofit.
Instead of:
@Target(AnnotationTarget.FUNCTION)
annotation class Headers(val value: Array<String>)
Change it to this:
@Target(AnnotationTarget.FUNCTION)
annotation class Headers(vararg val value: String)
Additional context
Changing the type to a vararg comes with one "disadvantage" The Headers would be set like this if you have multiple values:
@Headers("Accept: application/json", "Content-Type: application/json")
@GET
fun example(): Call<Example>
The current configuration looks like this:
@Headers(["Accept: application/json", "Content-Type: application/json"])
@GET
fun example(): Call<Example>