jsonapi icon indicating copy to clipboard operation
jsonapi copied to clipboard

Dealing with path prefixes

Open teleclimber opened this issue 5 years ago • 3 comments

Hi again,

How does one deal with path prefixes. For example say y API is at

https://somesite.com/api/v0/

When I try to load:

https://somesite.com/api/v0/widgets/2/

It tells me that "api" is not a known resource.

I could fake it by altering the URL of the incoming request, but then all the urls embedded in the JSON would be wrong?

AFAIK it's pretty common to for APIs to have path prefixes like /api/. IS there a way to deal with this that I missed? Thanks.

teleclimber avatar Jan 01 '21 23:01 teleclimber

This is a feature that does not exist because I simply didn't need it and didn't think about it. But it's definitely needed. I'll see what can be done. Right now, I'm thinking about some sort of URLOptions struct that can be passed to functions used to create a SimpleURL or a URL.

mfcochauxlaberge avatar Jan 02 '21 15:01 mfcochauxlaberge

Great thanks.

Right now, I'm thinking about some sort of URLOptions struct that can be passed to functions used to create a SimpleURL or a URL.

I agree, this is where I was thinking the path prefix would be specified.

teleclimber avatar Jan 02 '21 18:01 teleclimber

Done: https://github.com/mfcochauxlaberge/jsonapi/pull/115

mfcochauxlaberge avatar Jul 28 '22 16:07 mfcochauxlaberge