1 changed files with 0 additions and 27 deletions
@ -1,27 +0,0 @@
|
||||
#ifndef _TOREST_RESOURCE_HPP_ |
||||
#define _TOREST_RESOURCE_HPP_ |
||||
|
||||
#include <http.hpp> |
||||
|
||||
class resource_base { |
||||
friend std::ostream& operator<<(std::ostream& os,const resource_base& rs) |
||||
{ os << rs.json_response; return os; } |
||||
public: |
||||
virtual ~resource_base(){} |
||||
/// GET Read 200 (OK), list of customers. Use pagination, sorting and filtering to navigate big lists. 200 (OK), single customer. 404 (Not Found), if ID not found or invalid.
|
||||
virtual void get(nlohmann::json data=nullptr){} |
||||
/// PATCH Update/Modify 404 (Not Found), unless you want to modify the collection itself. 200 (OK) or 204 (No Content). 404 (Not Found), if ID not found or invalid.
|
||||
virtual void patch(nlohmann::json data=nullptr){} |
||||
/// POST Create 201 (Created), 'Location' header with link to /customers/{id} containing new ID. 404 (Not Found), 409 (Conflict) if resource already exists..
|
||||
virtual void post(nlohmann::json data=nullptr){} |
||||
/// DELETE Delete 404 (Not Found), unless you want to delete the whole collection—not often desirable. 200 (OK). 404 (Not Found), if ID not found or invalid.
|
||||
virtual void del(nlohmann::json data=nullptr){} |
||||
/// PUT Update/Replace 404 (Not Found), unless you want to update/replace every resource in the entire collection. 200 (OK) or 204 (No Content). 404 (Not Found), if ID not found or invalid.
|
||||
virtual void put(nlohmann::json data=nullptr){} |
||||
/// get a reference to the underlying JSON response
|
||||
http::response& get_response(){ return json_response; } |
||||
protected: |
||||
http::response json_response; |
||||
}; |
||||
|
||||
#endif // _TOREST_RESOURCE_HPP_
|
||||
Loading…
Reference in new issue