jean
10/26/2022, 8:17 PM@Serializable
@Resource("/search")
class Search(
val query: String? = null,
val offset: Offset? = null,
val limit: Limit? = null,
) : ApiResource() {
@Serializable
@Resource("type1")
class Type1(
val parent: Search = Search(),
val query: String,
val offset: Offset,
val limit: Limit,
)
@Serializable
@Resource("type2")
class Type2(
val parent: Search = Search(),
val query: String,
val offset: Offset,
val limit: Limit,
)
...
get<ApiResource.Search> { request ->
call.respond("search works. Query: ${request.query}") // This works
}
get<ApiResource.Search.Type1> { request ->
call.respond("search type1 works. Query: ${request.query}") // this gives me a 404 error
}
What am I supposed to change to make it work? The parameter query
is used to search by name in a database. /query
will search for both type1
and type2
while search/type1
should return only type1
resultsAleksei Tirman [JB]
10/27/2022, 8:36 AMquery
, offset
and limit
are required and you don’t list those parameters in the Resource
annotation (@Resource("type1")
) you have to make a request with corresponding query parameters, e.g. /search/type1?query=123&offset=1&limit=10
, otherwise that route won’t be matched.jean
10/27/2022, 5:11 PMquery
, offset
and limit
without repeating it for each child?