0

I had a problem when implementing RESTful Web Service, does all RESTful routes always contains GET, POST, PUT, DELETE? For example, i have Candidate and User model, should i serve those HTTP methods in my route?

Thanks, sorry for my bad English.

2
  • What do you want to achieve in your application? Commented Jul 16, 2018 at 4:16
  • A selection process of candidates for recruitment. Commented Jul 16, 2018 at 4:18

1 Answer 1

1

does all RESTful routes always contains GET, POST, PUT, DELETE?

No. Only provide what's useful to you.

For example, i have Candidate and User model, should i serve those HTTP methods in my route?

Do you need those routes in your application? If so, yes. If not, no.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your answer sir, and if my route is used for multiple roles should i make separated route ? For example, i have guess role and admin role, does it matter if i use one route for both roles?
@GalihAnggara Typically, the routes are based on the data accessed. So, the Candidate model might use /candidates, and the User model might use /users. An admin or a regular user would use both of these routes, but they could each have different permissions. For example, perhaps regular users could only GET. The API server could inspect their access token or cookie (or whatever you're using for authentication) and decide whether or not to authorize the user to perform the action they're requesting.
@GalihAnggara I should point out too that you should do whatever works for you. There is no strict standard... only common practices. Following common practices will make it easy for others to work with you on your application, and have often evolved that way to make it easy for you, but you may deviate if you have a specific reason to do so.
Wow it makes clear sir, Thanks. So, should i make routes for all models sir?
@GalihAnggara Only build what you need to build. Most of my projects have some internal models that are not accessible via the API.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.