66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
}
- (OFPlugin <Module> *)loadModuleAtPath: (OFString *)path
withConfig: (OFXMLElement *)config
{
OFPlugin <Module> *module;
of_log(@"Loading module at %@", path);
module = [OFPlugin pluginFromFile: path];
[module parseConfig: config];
return module;
}
- (void)startWebserverWithListenConfig: (ListenConfig *)listenConfig
{
|
|
|
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
}
- (OFPlugin <Module> *)loadModuleAtPath: (OFString *)path
withConfig: (OFXMLElement *)config
{
OFPlugin <Module> *module;
OFLog(@"Loading module at %@", path);
module = [OFPlugin pluginWithPath: path];
[module parseConfig: config];
return module;
}
- (void)startWebserverWithListenConfig: (ListenConfig *)listenConfig
{
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
server.certificateFile = listenConfig.TLSCertificateFile;
server.privateKeyFile = listenConfig.TLSKeyFile;
}
server.numberOfThreads = [OFSystemInfo numberOfCPUs] + 1;
server.delegate = self;
of_log(@"Starting server on host %@ port %" PRIu16,
listenConfig.host, listenConfig.port);
[server start];
}
- (void)server: (OFHTTPServer *)server
didReceiveRequest: (OFHTTPRequest *)request
requestBody: (OFStream *)requestBody
response: (OFHTTPResponse *)response
{
OFString *path = request.URL.path;
of_log(@"Request: %@", request);
for (OFPair OF_GENERIC(OFString *, id <Module>) *module in _modules)
if ([path hasPrefix: module.firstObject])
if ([module.secondObject handleRequest: request
requestBody: requestBody
response: response])
return;
}
- (bool)server: (OFHTTPServer *)server
didReceiveExceptionOnListeningSocket: (id)exception
{
of_log(@"Exception on listening socket: %@", exception);
return true;
}
@end
|
|
|
|
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
server.certificateFile = listenConfig.TLSCertificateFile;
server.privateKeyFile = listenConfig.TLSKeyFile;
}
server.numberOfThreads = [OFSystemInfo numberOfCPUs] + 1;
server.delegate = self;
OFLog(@"Starting server on host %@ port %" PRIu16,
listenConfig.host, listenConfig.port);
[server start];
}
- (void)server: (OFHTTPServer *)server
didReceiveRequest: (OFHTTPRequest *)request
requestBody: (OFStream *)requestBody
response: (OFHTTPResponse *)response
{
OFString *path = request.URL.path;
OFLog(@"Request: %@", request);
for (OFPair OF_GENERIC(OFString *, id <Module>) *module in _modules)
if ([path hasPrefix: module.firstObject])
if ([module.secondObject handleRequest: request
requestBody: requestBody
response: response])
return;
}
- (bool)server: (OFHTTPServer *)server
didReceiveExceptionOnListeningSocket: (id)exception
{
OFLog(@"Exception on listening socket: %@", exception);
return true;
}
@end
|