Seven RESTful Routes You Should

作者: 此之木 | 来源:发表于2019-10-09 06:28 被阅读0次

    I have been followed the course to develop several app projects. They all follow the RESTful route pattern. Today, I learned many key points about RESTful and would like to share my study note here.

    What Is REST?

    REST stands for representational state transfer. I don’t know what does this mean, but it is not important right now.You just need to know that REST is just a pattern for defining our routes.

    What’s The Point Of REST?

    The important things for us is to define what REST is.

    REST is a way of mapping HTTP routes and CRUD functionality together. By the way CRUD stands for Create, Read, Update, and Destroy.

    The point of REST is that we don’t do whatever we want. Instead, we follow a pattern.It is also more reliable so that if we are interacting with a restful API, it follows a particular pattern.

    Seven RESTful Routes

    The course lists the seven route table. It just acts as a pattern that we can fill in the blanks when we develop our own App.

    screenshot from course video

    1. Index Route

    The URL is “/dogs”, and you can change the “/XX” depends on your App. The purpose is to list all the relevant data, in this case, all dogs.

    2. New & Create Routes

    New and Create routes are linked to each other. Both of them are for creating new data.

    The HTTP verb of Create is “Post”. The post is where we go to post form data to create a new data and then redirect to somewhere.

    3. Show Route

    The point of Show route is to show detail information about one particular data.

    4. Edit & Update Routes

    Edit and Update routes are linked to each other, too. They correspond to one another.

    Edit is going to show us the form. Update is where the form submits.

    Moreover, Update’s HTTP verb is “Put” request. The process inside Update is that we need to find the old data first and then update it with new data. The purpose of  “Put” request is to update something rather than posting new things.

    5. Destroy

    Destroy is a single route. It’s going to delete request to the “/dogs/:id”. The point is that Destroy leads to a particular thing and then redirect somewhere.

    相关文章

      网友评论

        本文标题:Seven RESTful Routes You Should

        本文链接:https://www.haomeiwen.com/subject/aszpxctx.html