-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpServiceInstance
More file actions
96 lines (72 loc) · 2.7 KB
/
HttpServiceInstance
File metadata and controls
96 lines (72 loc) · 2.7 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#pragma once
#include <cc/HttpServiceDelegate>
#include <cc/HttpMediaTypeDatabase>
#include <cc/HttpLoggingServiceInstance>
#include <cc/TlsServerOptions>
#include <cc/Pattern>
namespace cc {
class HttpServiceWorkerState;
/** \class HttpServiceInstance cc/HttpServiceInstance
* \ingroup http_server
* \brief Configured instance of a delivery service
*/
class HttpServiceInstance: public Object
{
public:
/** Create a null delivery instance
*/
HttpServiceInstance() = default;
String serviceName() const { return me().serviceName_; }
long requestLimit() const { return me().requestLimit_; }
long requestPayloadLimit() const { return me().requestPayloadLimit_; }
Pattern host() const { return me().host_; }
Pattern uri() const { return me().uri_; }
TlsServerOptions tlsOptions() const { return me().tlsOptions_; }
HttpMediaTypeDatabase mediaTypes() const { return me().mediaTypes_; }
const HttpLoggingServiceInstance &errorLoggingInstance() const { return me().errorLoggingInstance_; }
const HttpLoggingServiceInstance &accessLoggingInstance() const { return me().accessLoggingInstance_; }
HttpServiceDelegate createDelegate() const { return me().createDelegate(); }
protected:
friend class Object;
friend class HttpServerConfig;
/** \brief %Internal state
*/
struct State: public Object::State
{
/** Initialize this instance with given \a config
*/
explicit State(const MetaObject &config);
/** Create a HTTP service delegate
*/
virtual HttpServiceDelegate createDelegate() const = 0;
const HttpLoggingServiceInstance &errorLoggingInstance() const { return errorLoggingInstance_; }
const HttpLoggingServiceInstance &accessLoggingInstance() const { return accessLoggingInstance_; }
private:
friend class HttpServiceInstance;
friend class HttpServerConfig;
String serviceName_;
long requestLimit_ { 0 };
long requestPayloadLimit_ { 0 };
Pattern host_;
Pattern uri_;
TlsServerOptions tlsOptions_;
HttpMediaTypeDatabase mediaTypes_;
HttpLoggingServiceInstance errorLoggingInstance_;
HttpLoggingServiceInstance accessLoggingInstance_;
};
explicit HttpServiceInstance(State *newState):
Object{newState}
{}
State &me() { return Object::me.as<State>(); }
const State &me() const { return Object::me.as<State>(); }
private:
State *operator->() { return &me(); }
};
} // namespace cc