Closed alazirakaclan closed 3 years ago
Thanks for your issue! If I understood correctly, you can - and should - use Vapors route groups for this. (See here)
let api = app.grouped("site", "api")
api.crud("todos", ...)
Anyhow I can make CRUDController
public if you want to extend RoutesBuilder
for this. Feel free to make a PR!
@alazirakaclan Can I close this issue?
I'd like to get responses on e.g. "/site/api/todos". And it seems it's not possible to do it right now, cause "app.crud(...)" accepts only one string.
I thought about something like this:
` extension RoutesBuilder { public func crud<T: Model & CRUDModel>(_ endpoints: [String], model: T.Type, custom: ((RoutesBuilder, CRUDController) -> ())? = nil) where T.IDValue: LosslessStringConvertible {
let endpoint = endpoints.last!
let modelComponents = endpoints.map{endpoint in PathComponent(stringLiteral: endpoint)}
let idComponents = modelComponents + [PathComponent(stringLiteral: ":(endpoint)")]
} `
But I can't use it, because CRUDController is internal.