1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine code for api, add clients and parse_rest_id

This commit is contained in:
winlin 2015-08-21 16:12:48 +08:00
parent ab4620870d
commit a7589b9ad3
7 changed files with 93 additions and 10 deletions

View file

@ -78,6 +78,7 @@ class ISrsHttpResponseWriter;
// helper function: response in json format.
extern int srs_http_response_json(ISrsHttpResponseWriter* w, std::string data);
extern int srs_http_response_code(ISrsHttpResponseWriter* w, int code);
// get the status text of code.
extern std::string srs_generate_http_status_text(int status);
@ -488,6 +489,14 @@ public:
virtual std::string host() = 0;
virtual std::string path() = 0;
virtual std::string ext() = 0;
/**
* get the RESTful id,
* for example, pattern is /api/v1/streams, path is /api/v1/streams/100,
* then the rest id is 100.
* @param pattern the handler pattern which will serve the request.
* @return the REST id; -1 if not matched.
*/
virtual int parse_rest_id(std::string pattern) = 0;
public:
/**
* read body to string.