agoo 2.15.7 → 2.15.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/bin/agoo +47 -39
- data/ext/agoo/bind.c +209 -198
- data/ext/agoo/con.c +19 -9
- data/ext/agoo/con.h +2 -0
- data/ext/agoo/req.c +7 -0
- data/ext/agoo/req.h +2 -0
- data/ext/agoo/request.c +29 -0
- data/ext/agoo/rgraphql.c +7 -4
- data/ext/agoo/rserver.c +714 -688
- data/ext/agoo/rserver.h +1 -0
- data/ext/agoo/server.c +255 -253
- data/lib/agoo/version.rb +1 -1
- data/lib/agoo.rb +1 -0
- data/lib/rack/handler/agoo.rb +138 -130
- metadata +2 -2
data/ext/agoo/req.h
CHANGED
@@ -31,6 +31,7 @@ typedef struct _agooReq {
|
|
31
31
|
struct _agooUpgraded *up;
|
32
32
|
struct _agooStr path;
|
33
33
|
struct _agooStr query;
|
34
|
+
struct _agooStr protocol;
|
34
35
|
struct _agooStr header;
|
35
36
|
struct _agooStr body;
|
36
37
|
char remote[INET6_ADDRSTRLEN];
|
@@ -43,6 +44,7 @@ typedef struct _agooReq {
|
|
43
44
|
extern agooReq agoo_req_create(size_t mlen);
|
44
45
|
extern void agoo_req_destroy(agooReq req);
|
45
46
|
extern const char* agoo_req_host(agooReq r, int *lenp);
|
47
|
+
extern const char* agoo_req_protocol(agooReq r, int *lenp);
|
46
48
|
extern int agoo_req_port(agooReq r);
|
47
49
|
extern const char* agoo_req_query_value(agooReq r, const char *key, int klen, int *vlenp);
|
48
50
|
extern int agoo_req_query_decode(char *s, int len);
|
data/ext/agoo/request.c
CHANGED
@@ -48,6 +48,7 @@ static VALUE request_method_val = Qundef;
|
|
48
48
|
static VALUE script_name_val = Qundef;
|
49
49
|
static VALUE server_name_val = Qundef;
|
50
50
|
static VALUE server_port_val = Qundef;
|
51
|
+
static VALUE server_protocol_val = Qundef;
|
51
52
|
static VALUE slash_val = Qundef;
|
52
53
|
|
53
54
|
static VALUE sse_sym;
|
@@ -218,6 +219,31 @@ server_name(VALUE self) {
|
|
218
219
|
return req_server_name((agooReq)DATA_PTR(self));
|
219
220
|
}
|
220
221
|
|
222
|
+
static VALUE
|
223
|
+
req_server_protocol(agooReq r) {
|
224
|
+
int len;
|
225
|
+
const char *protocol;
|
226
|
+
|
227
|
+
if (NULL == r) {
|
228
|
+
rb_raise(rb_eArgError, "Request is no longer valid.");
|
229
|
+
}
|
230
|
+
if (NULL == (protocol = agoo_req_protocol(r, &len))) {
|
231
|
+
return rb_str_new2("HTTP/1.1");
|
232
|
+
}
|
233
|
+
return rb_str_new(protocol, len);
|
234
|
+
}
|
235
|
+
|
236
|
+
/* Document-method: server_protocol
|
237
|
+
*
|
238
|
+
* call-seq: server_protocol()
|
239
|
+
*
|
240
|
+
* Returns the server or host protocol.
|
241
|
+
*/
|
242
|
+
static VALUE
|
243
|
+
server_protocol(VALUE self) {
|
244
|
+
return req_server_protocol((agooReq)DATA_PTR(self));
|
245
|
+
}
|
246
|
+
|
221
247
|
static VALUE
|
222
248
|
req_server_port(agooReq r) {
|
223
249
|
int len;
|
@@ -594,6 +620,7 @@ request_env(agooReq req, VALUE self) {
|
|
594
620
|
rb_hash_aset(env, remote_addr_val, req_remote_addr(req));
|
595
621
|
rb_hash_aset(env, server_port_val, req_server_port(req));
|
596
622
|
rb_hash_aset(env, server_name_val, req_server_name(req));
|
623
|
+
rb_hash_aset(env, server_protocol_val, req_server_protocol(req));
|
597
624
|
fill_headers(req, env);
|
598
625
|
rb_hash_aset(env, rack_version_val, rack_version_val_val);
|
599
626
|
rb_hash_aset(env, rack_url_scheme_val, req_rack_url_scheme(req));
|
@@ -739,6 +766,7 @@ request_init(VALUE mod) {
|
|
739
766
|
rb_define_method(req_class, "query_string", query_string, 0);
|
740
767
|
rb_define_method(req_class, "server_name", server_name, 0);
|
741
768
|
rb_define_method(req_class, "server_port", server_port, 0);
|
769
|
+
rb_define_method(req_class, "server_protocol", server_protocol, 0);
|
742
770
|
rb_define_method(req_class, "remote_addr", remote_addr, 0);
|
743
771
|
rb_define_method(req_class, "rack_version", rack_version, 0);
|
744
772
|
rb_define_method(req_class, "rack_url_scheme", rack_url_scheme, 0);
|
@@ -796,6 +824,7 @@ request_init(VALUE mod) {
|
|
796
824
|
script_name_val = rb_str_new_cstr("SCRIPT_NAME"); rb_gc_register_address(&script_name_val);
|
797
825
|
server_name_val = rb_str_new_cstr("SERVER_NAME"); rb_gc_register_address(&server_name_val);
|
798
826
|
server_port_val = rb_str_new_cstr("SERVER_PORT"); rb_gc_register_address(&server_port_val);
|
827
|
+
server_protocol_val = rb_str_new_cstr("SERVER_PROTOCOL"); rb_gc_register_address(&server_protocol_val);
|
799
828
|
slash_val = rb_str_new_cstr("/"); rb_gc_register_address(&slash_val);
|
800
829
|
|
801
830
|
sse_sym = ID2SYM(rb_intern("sse")); rb_gc_register_address(&sse_sym);
|
data/ext/agoo/rgraphql.c
CHANGED
@@ -406,6 +406,9 @@ ref_type(gqlRef ref) {
|
|
406
406
|
TypeClass tc;
|
407
407
|
const char *classname = rb_obj_classname((VALUE)ref);
|
408
408
|
|
409
|
+
if (RUBY_T_ARRAY == rb_type((VALUE)ref) && 0 < RARRAY_LEN((VALUE)ref)) {
|
410
|
+
classname = rb_obj_classname(RARRAY_AREF((VALUE)ref, 0));
|
411
|
+
}
|
409
412
|
for (tc = type_class_map; NULL != tc->type; tc++) {
|
410
413
|
if (0 == strcmp(classname, tc->classname)) {
|
411
414
|
type = tc->type;
|
@@ -436,8 +439,8 @@ resolve(agooErr err, gqlDoc doc, gqlRef target, gqlField field, gqlSel sel, gqlV
|
|
436
439
|
ID method;
|
437
440
|
int arity;
|
438
441
|
|
439
|
-
if ('_' == *
|
440
|
-
if (0 == strcmp("__typename",
|
442
|
+
if ('_' == *key && '_' == key[1]) {
|
443
|
+
if (0 == strcmp("__typename", key)) {
|
441
444
|
if (AGOO_ERR_OK != gql_set_typename(err, ref_type(target), key, result)) {
|
442
445
|
return err->code;
|
443
446
|
}
|
@@ -447,9 +450,9 @@ resolve(agooErr err, gqlDoc doc, gqlRef target, gqlField field, gqlSel sel, gqlV
|
|
447
450
|
case GQL_QUERY:
|
448
451
|
return gql_intro_eval(err, doc, sel, result, depth);
|
449
452
|
case GQL_MUTATION:
|
450
|
-
return agoo_err_set(err, AGOO_ERR_EVAL, "%s can not be called on a mutation.",
|
453
|
+
return agoo_err_set(err, AGOO_ERR_EVAL, "%s can not be called on a mutation.", key);
|
451
454
|
case GQL_SUBSCRIPTION:
|
452
|
-
return agoo_err_set(err, AGOO_ERR_EVAL, "%s can not be called on a subscription.",
|
455
|
+
return agoo_err_set(err, AGOO_ERR_EVAL, "%s can not be called on a subscription.", key);
|
453
456
|
default:
|
454
457
|
return agoo_err_set(err, AGOO_ERR_EVAL, "Not a valid operation on the root object.");
|
455
458
|
}
|