objective-php / rest-action
支持REST(ful)的PSR-15中间件库
v3.0.1
2019-06-02 22:05 UTC
Requires
- php: >=7.3
- aura/accept: ^2.2
- composer/semver: ^1.4
- objective-php/http-action: ^3.0
- objective-php/services-factory: ^3.0
Requires (Dev)
- codeception/codeception: ^3.0
This package is not auto-updated.
Last update: 2024-09-15 23:02:33 UTC
README
支持REST(ful)的PSR-15中间件库
入门
RestAction提供了一种简单的方式来构建版本化的API端点,并支持主动内容协商。
$action = new RestAction(); /* * Assume our RestAction has `application/xml` and `application/json` available * as media types, in order of highest-to-lowest preference for delivery */ $action->registerSerializer('application/*json', JsonSerializer::class); /* * Assume our RestAction has two Endpoints version available with * requests like `https://api.example/users` with `API-VERSION:1.0.0` or `API-VERSION:2.0.0` header * * Note that it support Semver matching, so the resource is also available with * requests like `https://api.example/users` with `API-VERSION:1` or `API-VERSION:2` header */ $action->registerEndpoint('1.0.0', UsersEndpointV1::class); $action->registerEndpoint('2.0.0', UsersEndpointV2::class);