Closed dancesWithCycles closed 1 year ago
The difference between the parameters url_prefix
and url_format
is that the url_format
accepts variables, when the url_prefix
doesn't.
I added the url_prefix
value to make the endpoints configuration more readable if you intend to use large urls, but always with the same prefix, such as:
/myApp/api/v1/users/login
/myApp/api/v1/users/info
/myApp/api/v1/users/[userID]/info
/myApp/api/v1/registration/[uuid]
in that case, using the url_prefix
value myApp/api/v1
makes sense, so your url_format
values can focus on what's important.
In your case, it's up to you whether you prefer using different url_prefix
values depending on their goal (/users
, /registration
, /password
) or not.
There is no better solution, and both solutions (with or without url_prefix
) are equivalent.
Cheers @babelouest for the explanation. Should be crystal clear by now.
Hi folks, Thank you so much for maintaining this repository! I am reading this API specification and wondering how to use
url_prefix
VS.url_format
inint ulfius_add_endpoint_by_val
.I like to transform the following existing REST API to ulfius.
/users/login GET /users/info GET /users/[userID]/info GET /users/update POST /users/create POST /users/email POST /registration/[uuid] GET /password/reset/[uuid] GET /password/reset POST /users/password/update POST /users/[id]/delete DELETE
You find parameters in square brackets and the HTML method as suffix.
What would be your suggestion on how to use prefix and format? Would you make e.g.
users
,registration
andpassword
a prefix and e.g.login
,info
,update
,create
,email
,reset
,update
anddelete
a format?Thank you so much for sharing!
Cheers!