-
Notifications
You must be signed in to change notification settings - Fork 8
/
playdar_request_handler.h
61 lines (47 loc) · 2.02 KB
/
playdar_request_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef __PLAYDAR_REQUEST_HANDLER_H__
#define __PLAYDAR_REQUEST_HANDLER_H__
#include <vector>
#include <string>
#include <iostream>
#include <moost/http.hpp>
#include <uriparser/Uri.h>
#include <uriparser/UriBase.h>
#include <uriparser/UriDefsAnsi.h>
#include <uriparser/UriDefsConfig.h>
#include <uriparser/UriDefsUnicode.h>
#include <uriparser/UriIp4.h>
#include "playdar/library.h"
#include "playdar/application.h"
#include "playdar/auth.hpp"
class playdar_request_handler : public moost::http::request_handler_base<playdar_request_handler>
{
public:
void init(MyApplication * app);
void handle_request(const moost::http::request& req, moost::http::reply& rep);
MyApplication * app() { return m_app; }
private:
playdar::auth * m_pauth;
// un%encode
string unescape(string s)
{
char * n = (char *) malloc(sizeof(char) * s.length()+1);
memcpy(n, s.data(), s.length());
uriUnescapeInPlaceA(n);
string ret(n);
delete(n);
return ret;
}
string sid_to_url(source_uid sid);
int collect_params(const string & url, map<string,string> & vars);
void handle_json_query(string query, const moost::http::request& req, moost::http::reply& rep);
void handle_rest_api(map<string, string> querystring, const moost::http::request& req, moost::http::reply& rep, string permissions);
void serve_body(string reply, const moost::http::request& req, moost::http::reply& rep);
void serve_stats(const moost::http::request& req, moost::http::reply& rep);
void serve_static_file(const moost::http::request& req, moost::http::reply& rep);
void serve_track(const moost::http::request& req, moost::http::reply& rep, int tid);
void serve_sid(const moost::http::request& req, moost::http::reply& rep, source_uid sid);
void serve_dynamic( const moost::http::request& req, moost::http::reply& rep,
string tpl, map<string,string> vars);
MyApplication * m_app;
};
#endif // __PLAYDAR_REQUEST_HANDLER_H__