开发者

Right way for blog URLs

I'm trying to do blog application and I want main page to have this URL: http://localhost/blog and posts to have URLs like this: http://localhost/blog/post-slug-name. So now I'm trying to understand how other actions should look like. Should it be somethin开发者_StackOverflowg like this?

http://localhost/blog/post-slug-name/edit (GET/POST)
http://localhost/blog/post-slug-name (DELETE)
http://localhost/blog/create_new (GET/POST)

But I don't like to have "special case" create_new (because pattern is the same as for regular post). What is common way to do this?


If you have full control over how your server maps HTTP requests, you could use a POST to http://localhost/blog/post-slug-name/create to create a post using that slug name, returning a 201 Created status on success and a 409 Conflict if the page exists. The advantage of using a single create_new method is that it can handle conflict avoidance transparently and obviously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜