You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem statement:
I'm building an API. A portion of that said API is used for administrative tasks and some other part for endusers. I've got them separated by url.
I'm having a usecase which returns the data of a single user.
I would like to reuse this usecase in both portions of the api with a clean interface to do so.
In case of a user accessing this usecase (f.e. on a route "/user-info") I'm having a middleware which authenticates the user and provides his/her ID down the chain via context.
In case of the admin accessing this usecase (f.e. on a route "/admin/users/{userID}") the id of a user is provided via url-path.
To be able to reuse that usecase in both cases it would be needed to rewrite the mapping (which is, I believe, already possible) and to map the value from ctx to the usecase (which is a new request afaik).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Problem statement:
I'm building an API. A portion of that said API is used for administrative tasks and some other part for endusers. I've got them separated by url.
I'm having a usecase which returns the data of a single user.
I would like to reuse this usecase in both portions of the api with a clean interface to do so.
In case of a user accessing this usecase (f.e. on a route "/user-info") I'm having a middleware which authenticates the user and provides his/her ID down the chain via context.
In case of the admin accessing this usecase (f.e. on a route "/admin/users/{userID}") the id of a user is provided via url-path.
To be able to reuse that usecase in both cases it would be needed to rewrite the mapping (which is, I believe, already possible) and to map the value from ctx to the usecase (which is a new request afaik).
Beta Was this translation helpful? Give feedback.
All reactions