Closed y9san9 closed 4 years ago
I'm copy & pasting same parameters every time and it makes my code worse
Right now there is no way around it, if kotlin had vararg templates it would be fine, but the best shot at solving this is #10 and it would be quite a big change for the library.
Also if you use authentication you should rather use authenticated routes and the auth provider, it allows you to share logic on the endpoints to get the authenticated principal object directly
Okey, thanks for your reply. Waiting for #10
I have suggestion how to implement this
route<GetTasksParams>("/tasks"){ params ->
route<AuthParams>("/auth"){ otherParams ->
get<AnotherParams, ...> { anotherParams ->
}
}
post<SomeOtherParams, ...> { someOtherParams ->
}
}
I dont know about possibility to do this, but this syntax would be nice
that is not possible directly, sadly, but something like this would be possible
route<GetTasksParams>("/tasks"){ params ->
route<AuthParams>("/auth"){ otherParams ->
get<AnotherParams, ...> { anotherParams ->
val paramsInstance = this.getParams(params) // needs to be resolved explicitly
val otherParamsInstance = this.getParams(otherParams)
}
}
}
Oke, I understand. Can you implement this ?
not any time soon sadly, i'm quite busy at the moment and can only spare an hour here an there... If you think you can implement it feel free to open a pull request.
Okey, I will think more about it later and if I find better solution I'll implement it
I have this models and I am using auth param in almost every request (there can be other parameter, not only auth). Can I somehow create data class with this param and then use it in other classes. My vision of it is in screenshot