ResfulApiBundle for symfony(upda

2017-08-10  本文已影响0人  jonny_bo

resful api bundle for symfony

Method design:

Endpoints:

An Endpoint is a URL within your API which points to a specific Resource or a Collection of Resources.
If you were building a fictional API to represent several different Zoo’s, each containing many Animals (with an animal belonging to exactly one Zoo), employees (who can work at multiple zoos) and keeping track of the species of each animal, you might have the following endpoints:

When referring to what each endpoint can do, you’ll want to list valid HTTP Verb and Endpoint combinations. For example, here’s a semi-comprehensive list of actions one can perform with our fictional API. Notice that I’ve preceded each endpoint with the HTTP Verb, as this is the same notation used within an HTTP Request header

Resourse

GET: api/v2/users/1 ---> UsersResourse:view ---> return json {user}
POST: api/v2/users/1 ---> UsersResourse:update ---> return jsonEndpoints {user}
DELETE: api/v2/users/1 ---> UsersResourse:delete ---> return json {bool}


GET: api/v2/users ---> UsersResourse:index ---> return json {userList}
POST: api/v2/users ---> UsersResourse:create ---> return json {user}
OPTIONS: api/v2/users ---> UsersResourse:options ---> return json {options}

上一篇下一篇

猜你喜欢

热点阅读