✅ Is it possible to access a Controller's URI at runtime?
I'm not well versed in MVC structures, so this very well could be a XY problem. Let me know if it is a bad idea to begin with.
I'm trying to create a GET endpoint for
On its own, this is not a problem. However, I am creating my API based around
So when accessing a returned
It looks sort of like this:
Endpoints:
This is all well and good, but I have some concerns with generating the embedded collection's link.
If I hardcode it as
Is it possible to access the
I'm trying to create a GET endpoint for
/collections which returns Collections. One Collection always contains a nested Model User.On its own, this is not a problem. However, I am creating my API based around
application/hal+json, which requires Resources to have a link to point to their exact location.So when accessing a returned
Collection, I could use its related link if I wish to access it directly instead.It looks sort of like this:
Endpoints:
/collections/collections/{uuid}This is all well and good, but I have some concerns with generating the embedded collection's link.
If I hardcode it as
$"http://foo-api/collections/{uuid}", then I would have to change the domain in every location where I did it.Is it possible to access the
CollectionController#GetById(string uuid) somehow and extract its URI at runtime?