spikard 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +626 -553
- data/ext/spikard_rb/Cargo.toml +17 -16
- data/ext/spikard_rb/extconf.rb +10 -10
- data/ext/spikard_rb/src/lib.rs +6 -6
- data/lib/spikard/app.rb +374 -328
- data/lib/spikard/background.rb +27 -27
- data/lib/spikard/config.rb +396 -396
- data/lib/spikard/converters.rb +85 -85
- data/lib/spikard/handler_wrapper.rb +116 -116
- data/lib/spikard/provide.rb +228 -0
- data/lib/spikard/response.rb +109 -109
- data/lib/spikard/schema.rb +243 -243
- data/lib/spikard/sse.rb +111 -111
- data/lib/spikard/streaming_response.rb +21 -21
- data/lib/spikard/testing.rb +221 -220
- data/lib/spikard/upload_file.rb +131 -131
- data/lib/spikard/version.rb +5 -5
- data/lib/spikard/websocket.rb +59 -59
- data/lib/spikard.rb +43 -42
- data/sig/spikard.rbs +349 -336
- data/vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.6.2/mise.toml +5 -0
- metadata +23 -5
data/sig/spikard.rbs
CHANGED
|
@@ -1,336 +1,349 @@
|
|
|
1
|
-
module Spikard
|
|
2
|
-
VERSION: String
|
|
3
|
-
|
|
4
|
-
module Background
|
|
5
|
-
def self.run: () { () -> void } -> void
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
class CompressionConfig
|
|
9
|
-
attr_accessor gzip: bool
|
|
10
|
-
attr_accessor brotli: bool
|
|
11
|
-
attr_accessor min_size: Integer
|
|
12
|
-
attr_accessor quality: Integer
|
|
13
|
-
|
|
14
|
-
def initialize: (?gzip: bool, ?brotli: bool, ?min_size: Integer, ?quality: Integer) -> void
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class RateLimitConfig
|
|
18
|
-
attr_accessor per_second: Integer
|
|
19
|
-
attr_accessor burst: Integer
|
|
20
|
-
attr_accessor ip_based: bool
|
|
21
|
-
|
|
22
|
-
def initialize: (per_second: Integer, burst: Integer, ?ip_based: bool) -> void
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
class JwtConfig
|
|
26
|
-
attr_accessor secret: String
|
|
27
|
-
attr_accessor algorithm: String
|
|
28
|
-
attr_accessor audience: Array[String]?
|
|
29
|
-
attr_accessor issuer: String?
|
|
30
|
-
attr_accessor leeway: Integer
|
|
31
|
-
|
|
32
|
-
def initialize: (secret: String, ?algorithm: String, ?audience: Array[String]?, ?issuer: String?, ?leeway: Integer) -> void
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
class ApiKeyConfig
|
|
36
|
-
attr_accessor keys: Array[String]
|
|
37
|
-
attr_accessor header_name: String
|
|
38
|
-
|
|
39
|
-
def initialize: (keys: Array[String], ?header_name: String) -> void
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
class StaticFilesConfig
|
|
43
|
-
attr_accessor directory: String
|
|
44
|
-
attr_accessor route_prefix: String
|
|
45
|
-
attr_accessor index_file: bool
|
|
46
|
-
attr_accessor cache_control: String?
|
|
47
|
-
|
|
48
|
-
def initialize: (directory: String, route_prefix: String, ?index_file: bool, ?cache_control: String?) -> void
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
class ContactInfo
|
|
52
|
-
attr_accessor name: String?
|
|
53
|
-
attr_accessor email: String?
|
|
54
|
-
attr_accessor url: String?
|
|
55
|
-
|
|
56
|
-
def initialize: (?name: String?, ?email: String?, ?url: String?) -> void
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
class LicenseInfo
|
|
60
|
-
attr_accessor name: String
|
|
61
|
-
attr_accessor url: String?
|
|
62
|
-
|
|
63
|
-
def initialize: (name: String, ?url: String?) -> void
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
class ServerInfo
|
|
67
|
-
attr_accessor url: String
|
|
68
|
-
attr_accessor description: String?
|
|
69
|
-
|
|
70
|
-
def initialize: (url: String, ?description: String?) -> void
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
class SecuritySchemeInfo
|
|
74
|
-
attr_accessor type: String
|
|
75
|
-
attr_accessor scheme: String?
|
|
76
|
-
attr_accessor bearer_format: String?
|
|
77
|
-
attr_accessor location: String?
|
|
78
|
-
attr_accessor name: String?
|
|
79
|
-
|
|
80
|
-
def initialize: (type: String, ?scheme: String?, ?bearer_format: String?, ?location: String?, ?name: String?) -> void
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
class OpenApiConfig
|
|
84
|
-
attr_accessor enabled: bool
|
|
85
|
-
attr_accessor title: String
|
|
86
|
-
attr_accessor version: String
|
|
87
|
-
attr_accessor description: String?
|
|
88
|
-
attr_accessor swagger_ui_path: String
|
|
89
|
-
attr_accessor redoc_path: String
|
|
90
|
-
attr_accessor openapi_json_path: String
|
|
91
|
-
attr_accessor contact: ContactInfo?
|
|
92
|
-
attr_accessor license: LicenseInfo?
|
|
93
|
-
attr_accessor servers: Array[ServerInfo]
|
|
94
|
-
attr_accessor security_schemes: Hash[String, SecuritySchemeInfo]
|
|
95
|
-
|
|
96
|
-
def initialize: (
|
|
97
|
-
?enabled: bool,
|
|
98
|
-
?title: String,
|
|
99
|
-
?version: String,
|
|
100
|
-
?description: String?,
|
|
101
|
-
?swagger_ui_path: String,
|
|
102
|
-
?redoc_path: String,
|
|
103
|
-
?openapi_json_path: String,
|
|
104
|
-
?contact: ContactInfo?,
|
|
105
|
-
?license: LicenseInfo?,
|
|
106
|
-
?servers: Array[ServerInfo],
|
|
107
|
-
?security_schemes: Hash[String, SecuritySchemeInfo]
|
|
108
|
-
) -> void
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
class ServerConfig
|
|
112
|
-
attr_accessor host: String
|
|
113
|
-
attr_accessor port: Integer
|
|
114
|
-
attr_accessor workers: Integer
|
|
115
|
-
attr_accessor enable_request_id: bool
|
|
116
|
-
attr_accessor max_body_size: Integer?
|
|
117
|
-
attr_accessor request_timeout: Integer?
|
|
118
|
-
attr_accessor compression: CompressionConfig
|
|
119
|
-
attr_accessor rate_limit: RateLimitConfig?
|
|
120
|
-
attr_accessor jwt_auth: JwtConfig?
|
|
121
|
-
attr_accessor api_key_auth: ApiKeyConfig?
|
|
122
|
-
attr_accessor static_files: Array[StaticFilesConfig]
|
|
123
|
-
attr_accessor graceful_shutdown: bool
|
|
124
|
-
attr_accessor shutdown_timeout: Integer
|
|
125
|
-
attr_accessor openapi: OpenApiConfig?
|
|
126
|
-
|
|
127
|
-
def initialize: (
|
|
128
|
-
?host: String,
|
|
129
|
-
?port: Integer,
|
|
130
|
-
?workers: Integer,
|
|
131
|
-
?enable_request_id: bool,
|
|
132
|
-
?max_body_size: Integer?,
|
|
133
|
-
?request_timeout: Integer?,
|
|
134
|
-
?compression: CompressionConfig,
|
|
135
|
-
?rate_limit: RateLimitConfig?,
|
|
136
|
-
?jwt_auth: JwtConfig?,
|
|
137
|
-
?api_key_auth: ApiKeyConfig?,
|
|
138
|
-
?static_files: Array[StaticFilesConfig],
|
|
139
|
-
?graceful_shutdown: bool,
|
|
140
|
-
?shutdown_timeout: Integer,
|
|
141
|
-
?openapi: OpenApiConfig?
|
|
142
|
-
) -> void
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
class Response
|
|
146
|
-
attr_accessor content: untyped
|
|
147
|
-
attr_reader status_code: Integer
|
|
148
|
-
attr_reader headers: Hash[String, String]
|
|
149
|
-
|
|
150
|
-
def initialize: (
|
|
151
|
-
?content: untyped,
|
|
152
|
-
?body: untyped,
|
|
153
|
-
?status_code: Integer,
|
|
154
|
-
?headers: Hash[untyped, untyped]?,
|
|
155
|
-
?content_type: String?
|
|
156
|
-
) -> void
|
|
157
|
-
def status: () -> Integer
|
|
158
|
-
def status_code=: (Integer) -> Integer
|
|
159
|
-
def headers=: (Hash[untyped, untyped]?) -> Hash[String, String]
|
|
160
|
-
def set_header: (String, String) -> String
|
|
161
|
-
def set_cookie: (
|
|
162
|
-
String,
|
|
163
|
-
String,
|
|
164
|
-
?max_age: Integer?,
|
|
165
|
-
?domain: String?,
|
|
166
|
-
?path: String?,
|
|
167
|
-
?secure: bool?,
|
|
168
|
-
?httponly: bool?,
|
|
169
|
-
?samesite: String?
|
|
170
|
-
) -> String
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
class StreamingResponse
|
|
174
|
-
attr_reader stream: Enumerable[untyped]
|
|
175
|
-
attr_reader status_code: Integer
|
|
176
|
-
attr_reader headers: Hash[String, String]
|
|
177
|
-
|
|
178
|
-
def initialize: (Enumerable[untyped], ?status_code: Integer, ?headers: Hash[untyped, untyped]?) -> void
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
module LifecycleHooks
|
|
182
|
-
def on_request: () { (untyped) -> untyped } -> Proc
|
|
183
|
-
def pre_validation: () { (untyped) -> untyped } -> Proc
|
|
184
|
-
def pre_handler: () { (untyped) -> untyped } -> Proc
|
|
185
|
-
def on_response: () { (untyped) -> untyped } -> Proc
|
|
186
|
-
def on_error: () { (untyped) -> untyped } -> Proc
|
|
187
|
-
def lifecycle_hooks: () -> Hash[Symbol, Array[Proc]]
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
def
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
def
|
|
208
|
-
def
|
|
209
|
-
def
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def
|
|
214
|
-
def
|
|
215
|
-
def
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
def
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def
|
|
272
|
-
def
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
def
|
|
285
|
-
def
|
|
286
|
-
def
|
|
287
|
-
def
|
|
288
|
-
def
|
|
289
|
-
def
|
|
290
|
-
def
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
def
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def
|
|
299
|
-
def
|
|
300
|
-
def
|
|
301
|
-
def
|
|
302
|
-
def
|
|
303
|
-
def
|
|
304
|
-
def
|
|
305
|
-
def
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
def
|
|
312
|
-
def
|
|
313
|
-
def
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
def
|
|
318
|
-
def
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
def
|
|
325
|
-
def
|
|
326
|
-
def
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
class
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
def
|
|
333
|
-
def
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
|
|
1
|
+
module Spikard
|
|
2
|
+
VERSION: String
|
|
3
|
+
|
|
4
|
+
module Background
|
|
5
|
+
def self.run: () { () -> void } -> void
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class CompressionConfig
|
|
9
|
+
attr_accessor gzip: bool
|
|
10
|
+
attr_accessor brotli: bool
|
|
11
|
+
attr_accessor min_size: Integer
|
|
12
|
+
attr_accessor quality: Integer
|
|
13
|
+
|
|
14
|
+
def initialize: (?gzip: bool, ?brotli: bool, ?min_size: Integer, ?quality: Integer) -> void
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class RateLimitConfig
|
|
18
|
+
attr_accessor per_second: Integer
|
|
19
|
+
attr_accessor burst: Integer
|
|
20
|
+
attr_accessor ip_based: bool
|
|
21
|
+
|
|
22
|
+
def initialize: (per_second: Integer, burst: Integer, ?ip_based: bool) -> void
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class JwtConfig
|
|
26
|
+
attr_accessor secret: String
|
|
27
|
+
attr_accessor algorithm: String
|
|
28
|
+
attr_accessor audience: Array[String]?
|
|
29
|
+
attr_accessor issuer: String?
|
|
30
|
+
attr_accessor leeway: Integer
|
|
31
|
+
|
|
32
|
+
def initialize: (secret: String, ?algorithm: String, ?audience: Array[String]?, ?issuer: String?, ?leeway: Integer) -> void
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class ApiKeyConfig
|
|
36
|
+
attr_accessor keys: Array[String]
|
|
37
|
+
attr_accessor header_name: String
|
|
38
|
+
|
|
39
|
+
def initialize: (keys: Array[String], ?header_name: String) -> void
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class StaticFilesConfig
|
|
43
|
+
attr_accessor directory: String
|
|
44
|
+
attr_accessor route_prefix: String
|
|
45
|
+
attr_accessor index_file: bool
|
|
46
|
+
attr_accessor cache_control: String?
|
|
47
|
+
|
|
48
|
+
def initialize: (directory: String, route_prefix: String, ?index_file: bool, ?cache_control: String?) -> void
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ContactInfo
|
|
52
|
+
attr_accessor name: String?
|
|
53
|
+
attr_accessor email: String?
|
|
54
|
+
attr_accessor url: String?
|
|
55
|
+
|
|
56
|
+
def initialize: (?name: String?, ?email: String?, ?url: String?) -> void
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class LicenseInfo
|
|
60
|
+
attr_accessor name: String
|
|
61
|
+
attr_accessor url: String?
|
|
62
|
+
|
|
63
|
+
def initialize: (name: String, ?url: String?) -> void
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class ServerInfo
|
|
67
|
+
attr_accessor url: String
|
|
68
|
+
attr_accessor description: String?
|
|
69
|
+
|
|
70
|
+
def initialize: (url: String, ?description: String?) -> void
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class SecuritySchemeInfo
|
|
74
|
+
attr_accessor type: String
|
|
75
|
+
attr_accessor scheme: String?
|
|
76
|
+
attr_accessor bearer_format: String?
|
|
77
|
+
attr_accessor location: String?
|
|
78
|
+
attr_accessor name: String?
|
|
79
|
+
|
|
80
|
+
def initialize: (type: String, ?scheme: String?, ?bearer_format: String?, ?location: String?, ?name: String?) -> void
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class OpenApiConfig
|
|
84
|
+
attr_accessor enabled: bool
|
|
85
|
+
attr_accessor title: String
|
|
86
|
+
attr_accessor version: String
|
|
87
|
+
attr_accessor description: String?
|
|
88
|
+
attr_accessor swagger_ui_path: String
|
|
89
|
+
attr_accessor redoc_path: String
|
|
90
|
+
attr_accessor openapi_json_path: String
|
|
91
|
+
attr_accessor contact: ContactInfo?
|
|
92
|
+
attr_accessor license: LicenseInfo?
|
|
93
|
+
attr_accessor servers: Array[ServerInfo]
|
|
94
|
+
attr_accessor security_schemes: Hash[String, SecuritySchemeInfo]
|
|
95
|
+
|
|
96
|
+
def initialize: (
|
|
97
|
+
?enabled: bool,
|
|
98
|
+
?title: String,
|
|
99
|
+
?version: String,
|
|
100
|
+
?description: String?,
|
|
101
|
+
?swagger_ui_path: String,
|
|
102
|
+
?redoc_path: String,
|
|
103
|
+
?openapi_json_path: String,
|
|
104
|
+
?contact: ContactInfo?,
|
|
105
|
+
?license: LicenseInfo?,
|
|
106
|
+
?servers: Array[ServerInfo],
|
|
107
|
+
?security_schemes: Hash[String, SecuritySchemeInfo]
|
|
108
|
+
) -> void
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
class ServerConfig
|
|
112
|
+
attr_accessor host: String
|
|
113
|
+
attr_accessor port: Integer
|
|
114
|
+
attr_accessor workers: Integer
|
|
115
|
+
attr_accessor enable_request_id: bool
|
|
116
|
+
attr_accessor max_body_size: Integer?
|
|
117
|
+
attr_accessor request_timeout: Integer?
|
|
118
|
+
attr_accessor compression: CompressionConfig
|
|
119
|
+
attr_accessor rate_limit: RateLimitConfig?
|
|
120
|
+
attr_accessor jwt_auth: JwtConfig?
|
|
121
|
+
attr_accessor api_key_auth: ApiKeyConfig?
|
|
122
|
+
attr_accessor static_files: Array[StaticFilesConfig]
|
|
123
|
+
attr_accessor graceful_shutdown: bool
|
|
124
|
+
attr_accessor shutdown_timeout: Integer
|
|
125
|
+
attr_accessor openapi: OpenApiConfig?
|
|
126
|
+
|
|
127
|
+
def initialize: (
|
|
128
|
+
?host: String,
|
|
129
|
+
?port: Integer,
|
|
130
|
+
?workers: Integer,
|
|
131
|
+
?enable_request_id: bool,
|
|
132
|
+
?max_body_size: Integer?,
|
|
133
|
+
?request_timeout: Integer?,
|
|
134
|
+
?compression: CompressionConfig,
|
|
135
|
+
?rate_limit: RateLimitConfig?,
|
|
136
|
+
?jwt_auth: JwtConfig?,
|
|
137
|
+
?api_key_auth: ApiKeyConfig?,
|
|
138
|
+
?static_files: Array[StaticFilesConfig],
|
|
139
|
+
?graceful_shutdown: bool,
|
|
140
|
+
?shutdown_timeout: Integer,
|
|
141
|
+
?openapi: OpenApiConfig?
|
|
142
|
+
) -> void
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class Response
|
|
146
|
+
attr_accessor content: untyped
|
|
147
|
+
attr_reader status_code: Integer
|
|
148
|
+
attr_reader headers: Hash[String, String]
|
|
149
|
+
|
|
150
|
+
def initialize: (
|
|
151
|
+
?content: untyped,
|
|
152
|
+
?body: untyped,
|
|
153
|
+
?status_code: Integer,
|
|
154
|
+
?headers: Hash[untyped, untyped]?,
|
|
155
|
+
?content_type: String?
|
|
156
|
+
) -> void
|
|
157
|
+
def status: () -> Integer
|
|
158
|
+
def status_code=: (Integer) -> Integer
|
|
159
|
+
def headers=: (Hash[untyped, untyped]?) -> Hash[String, String]
|
|
160
|
+
def set_header: (String, String) -> String
|
|
161
|
+
def set_cookie: (
|
|
162
|
+
String,
|
|
163
|
+
String,
|
|
164
|
+
?max_age: Integer?,
|
|
165
|
+
?domain: String?,
|
|
166
|
+
?path: String?,
|
|
167
|
+
?secure: bool?,
|
|
168
|
+
?httponly: bool?,
|
|
169
|
+
?samesite: String?
|
|
170
|
+
) -> String
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
class StreamingResponse
|
|
174
|
+
attr_reader stream: Enumerable[untyped]
|
|
175
|
+
attr_reader status_code: Integer
|
|
176
|
+
attr_reader headers: Hash[String, String]
|
|
177
|
+
|
|
178
|
+
def initialize: (Enumerable[untyped], ?status_code: Integer, ?headers: Hash[untyped, untyped]?) -> void
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
module LifecycleHooks
|
|
182
|
+
def on_request: () { (untyped) -> untyped } -> Proc
|
|
183
|
+
def pre_validation: () { (untyped) -> untyped } -> Proc
|
|
184
|
+
def pre_handler: () { (untyped) -> untyped } -> Proc
|
|
185
|
+
def on_response: () { (untyped) -> untyped } -> Proc
|
|
186
|
+
def on_error: () { (untyped) -> untyped } -> Proc
|
|
187
|
+
def lifecycle_hooks: () -> Hash[Symbol, Array[Proc]]
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
module ProvideSupport
|
|
191
|
+
def provide: (
|
|
192
|
+
String | Symbol,
|
|
193
|
+
?untyped,
|
|
194
|
+
?depends_on: Array[String | Symbol],
|
|
195
|
+
?singleton: bool,
|
|
196
|
+
?cacheable: bool
|
|
197
|
+
) ?{ (**untyped) -> untyped } -> self
|
|
198
|
+
def dependencies: () -> Hash[String, untyped]
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
class App
|
|
202
|
+
include LifecycleHooks
|
|
203
|
+
include ProvideSupport
|
|
204
|
+
|
|
205
|
+
attr_reader routes: Array[untyped]
|
|
206
|
+
|
|
207
|
+
def initialize: () -> void
|
|
208
|
+
def register_route: (String, String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
209
|
+
def get: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
210
|
+
def post: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
211
|
+
def put: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
212
|
+
def patch: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
213
|
+
def delete: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
214
|
+
def options: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
215
|
+
def head: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
216
|
+
def trace: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
|
|
217
|
+
def websocket: (String, ?handler_name: String?, **untyped) { () -> WebSocketHandler } -> Proc
|
|
218
|
+
def sse: (String, ?handler_name: String?, **untyped) { () -> SseEventProducer } -> Proc
|
|
219
|
+
def websocket_handlers: () -> Hash[String, Proc]
|
|
220
|
+
def sse_producers: () -> Hash[String, Proc]
|
|
221
|
+
def run: (?config: ServerConfig | Hash[Symbol, untyped]?, ?host: String?, ?port: Integer?) -> void
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
class WebSocketHandler
|
|
225
|
+
def handle_message: (Hash[untyped, untyped]) -> Hash[untyped, untyped]?
|
|
226
|
+
def on_connect: () -> void
|
|
227
|
+
def on_disconnect: () -> void
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
class SseEvent
|
|
231
|
+
attr_accessor data: Hash[untyped, untyped]
|
|
232
|
+
attr_accessor event_type: String?
|
|
233
|
+
attr_accessor id: String?
|
|
234
|
+
attr_accessor retry_ms: Integer?
|
|
235
|
+
|
|
236
|
+
def initialize: (data: Hash[untyped, untyped], ?event_type: String?, ?id: String?, ?retry_ms: Integer?) -> void
|
|
237
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
class SseEventProducer
|
|
241
|
+
def next_event: () -> SseEvent?
|
|
242
|
+
def on_connect: () -> void
|
|
243
|
+
def on_disconnect: () -> void
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
module Schema
|
|
247
|
+
def self.extract_json_schema: (untyped) -> Hash[untyped, untyped]?
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
module Native
|
|
251
|
+
def self.run_server: (
|
|
252
|
+
String,
|
|
253
|
+
Hash[Symbol, Proc],
|
|
254
|
+
ServerConfig,
|
|
255
|
+
Hash[Symbol, Array[Proc]],
|
|
256
|
+
Hash[String, Proc],
|
|
257
|
+
Hash[String, Proc],
|
|
258
|
+
Hash[String, untyped]
|
|
259
|
+
) -> void
|
|
260
|
+
|
|
261
|
+
class TestClient
|
|
262
|
+
def initialize: (
|
|
263
|
+
String,
|
|
264
|
+
Hash[Symbol, Proc],
|
|
265
|
+
ServerConfig,
|
|
266
|
+
Hash[String, Proc],
|
|
267
|
+
Hash[String, Proc]
|
|
268
|
+
) -> void
|
|
269
|
+
def request: (String, String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
|
|
270
|
+
def websocket: (String) -> untyped
|
|
271
|
+
def sse: (String) -> untyped
|
|
272
|
+
def close: () -> void
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
module Testing
|
|
277
|
+
def self.create_test_client: (App, ?config: ServerConfig?) -> Testing::TestClient
|
|
278
|
+
|
|
279
|
+
class Response
|
|
280
|
+
attr_reader status_code: Integer
|
|
281
|
+
attr_reader headers: Hash[String, String]
|
|
282
|
+
attr_reader body: String?
|
|
283
|
+
|
|
284
|
+
def initialize: (Hash[Symbol, untyped]) -> void
|
|
285
|
+
def status: () -> Integer
|
|
286
|
+
def body_bytes: () -> String
|
|
287
|
+
def body_text: () -> String?
|
|
288
|
+
def text: () -> String?
|
|
289
|
+
def json: () -> untyped
|
|
290
|
+
def bytes: () -> Array[Integer]
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
class TestClient
|
|
294
|
+
def initialize: (Spikard::Native::TestClient) -> void
|
|
295
|
+
def self.new: (App | Spikard::Native::TestClient, ?config: ServerConfig?) -> TestClient
|
|
296
|
+
def request: (String, String, **Hash[Symbol, untyped]) -> Response
|
|
297
|
+
def websocket: (String) -> WebSocketTestConnection
|
|
298
|
+
def sse: (String) -> SseStream
|
|
299
|
+
def close: () -> void
|
|
300
|
+
def get: (String, **Hash[Symbol, untyped]) -> Response
|
|
301
|
+
def post: (String, **Hash[Symbol, untyped]) -> Response
|
|
302
|
+
def put: (String, **Hash[Symbol, untyped]) -> Response
|
|
303
|
+
def patch: (String, **Hash[Symbol, untyped]) -> Response
|
|
304
|
+
def delete: (String, **Hash[Symbol, untyped]) -> Response
|
|
305
|
+
def head: (String, **Hash[Symbol, untyped]) -> Response
|
|
306
|
+
def options: (String, **Hash[Symbol, untyped]) -> Response
|
|
307
|
+
def trace: (String, **Hash[Symbol, untyped]) -> Response
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
class WebSocketTestConnection
|
|
311
|
+
def initialize: (untyped) -> void
|
|
312
|
+
def send_text: (untyped) -> void
|
|
313
|
+
def send_json: (untyped) -> void
|
|
314
|
+
def receive_text: () -> untyped
|
|
315
|
+
def receive_json: () -> untyped
|
|
316
|
+
def receive_bytes: () -> untyped
|
|
317
|
+
def receive_message: () -> WebSocketMessage
|
|
318
|
+
def close: () -> void
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
class WebSocketMessage
|
|
322
|
+
def initialize: (untyped) -> void
|
|
323
|
+
def as_text: () -> untyped
|
|
324
|
+
def as_json: () -> untyped
|
|
325
|
+
def as_binary: () -> untyped
|
|
326
|
+
def close?: () -> bool
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
class SseStream
|
|
330
|
+
def initialize: (untyped) -> void
|
|
331
|
+
def body: () -> String?
|
|
332
|
+
def events: () -> Array[InlineSseEvent]
|
|
333
|
+
def events_as_json: () -> Array[untyped]
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
class SseEvent
|
|
337
|
+
def initialize: (untyped) -> void
|
|
338
|
+
def data: () -> untyped
|
|
339
|
+
def as_json: () -> untyped
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
class InlineSseEvent
|
|
343
|
+
attr_reader data: String
|
|
344
|
+
|
|
345
|
+
def initialize: (String) -> void
|
|
346
|
+
def as_json: () -> untyped
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
end
|