How could I return different model based on role? Could I use two different middleware on same route with two different function? Like
adminRoute.get("day", use: adminDay)
managerRoute.get("day", use: managerDay)
@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]
I don’t think you’ll be able to do it like that because the router will get confused. You’ll have to return Response
in your route handler, that way you can return whatever you want depending on what comes into the request. Make sense?
I know I need to respond Response
but how could I respond different Content
based on role?
Don’t want to do with another route unless thats the only option
So you can’t respond directly with different Content
types based on role (because the compiler won’t allow it). What you can do is set your route handler to return Response
and encode the different content types into the response. That way you get one route handler returning different types that the compiler is happy with
End up using multiple routes. Saw that you are updating video course on Twitter, don’t forget for the book too.