xs/dispatch.xs

filter: Statementstmt 16.6% 2 / 18 (1 uncoverable) Branchbran 7.6% 2 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 11.3% 4 / 44 (1 uncoverable) CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/serve.xs ↑ Summary xs/url.xs »
1 MODULE = Punk PACKAGE = Punk
2  
3 PROTOTYPES: DISABLE
4  
5 # True when Open::API's C ABI (oa_abi.h) resolved at the compiled-against
6 # OA_ABI_VERSION. It always should - Open::API 0.04+ is a hard prerequisite -
7 # so this is really only for the guard test; punk_oa croaks on the request
8 # path if the table is missing. PUNK_FAKE_OA_BAD simulates a version mismatch.
9 int
10 _oa_available()
11 CODE:
12 13 ▶ RETVAL = punk_oa_try(aTHX) ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = punk_oa_try(aTHX) ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */ 0 13 13
13 OUTPUT:
14 RETVAL
15  
16 # The ABI version this was compiled against, for the guard test.
17 int
18 _oa_abi_version()
19 CODE:
20 6 ▶ RETVAL = OA_ABI_VERSION;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = OA_ABI_VERSION; 0 6 6
21 OUTPUT:
22 RETVAL
23  
24 # Dispatch one matched API operation entirely in C: the before-dispatch hooks
25 # and the operation's guards (short-circuitable), the 413/501 checks, raw-input
26 # assembly and validation through the ABI, stashing the typed params, and the
27 # controller call. Returns ($ret, $err) for Punk::App's finish path - $ret the
28 # controller's value or an early PSGI triplet (400/413/501/guard short-circuit),
29 # $err a die message or undef. The hooks, guards and controller are the only
30 # Perl frames.
31 void
32 # uncoverable statement
33 # uncoverable subroutine
34 _oa_dispatch(c, before, rec, api, op_id, caps, max_body)
35 SV *c
36 SV *before
37 SV *rec
38 SV *api
39 SV *op_id
40 SV *caps
41 IV max_body
42 PPCODE:
43 {
44 AV *before_av;
45 HV *rech;
46 SV *ret, *err;
47 0 ▶ # uncoverable statement
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable statement 0 0 0
# uncoverable statement 0 0 0
48 0 # uncoverable branch true
49 0 ▶ # uncoverable branch false
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable branch false 0 0 0
50 0 ▶ # uncoverable condition left count:1
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable condition left count:1 0 0 0
51 0 # uncoverable condition right count:1
52 0 # uncoverable condition left count:2
53 # uncoverable condition right count:2
54 0 if (!SvROK(rec) || SvTYPE(SvRV(rec)) != SVt_PVHV)
55 0 ▶ croak("Punk::_oa_dispatch: rec must be a hashref"); /* # uncoverable statement */
Branch: 1 branch
BranchTrueFalseTotal
croak("Punk::_oa_dispatch: rec must be a hashref"); /* # uncoverable statement */ 0 0 0
56 0 ▶ before_av = (SvROK(before) && SvTYPE(SvRV(before)) == SVt_PVAV) /* # uncoverable statement */
Branch: 1 branch
BranchTrueFalseTotal
before_av = (SvROK(before) && SvTYPE(SvRV(before)) == SVt_PVAV) /* # uncoverable statement */ 0 0 0
57 0 ▶ ? (AV *)SvRV(before) : NULL; /* # uncoverable statement */
Branch: 1 branch
BranchTrueFalseTotal
? (AV *)SvRV(before) : NULL; /* # uncoverable statement */ 0 0 0
58 rech = (HV *)SvRV(rec); /* # uncoverable statement */
59 punk_oa_dispatch(aTHX_ c, before_av, rech, api, op_id, caps, /* # uncoverable statement */
60 max_body, &ret, &err); /* # uncoverable statement */
61 SP = PL_stack_base + ax - 1; /* hooks and the controller ran */ /* # uncoverable statement */
62 EXTEND(SP, 2); /* # uncoverable statement */
63 # uncoverable statement
64 # uncoverable condition left count:1
65 # uncoverable condition right count:1
66 PUSHs(ret == &PL_sv_undef ? ret : sv_2mortal(ret));
67 # uncoverable statement
68 # uncoverable condition left count:1
69 # uncoverable condition right count:1
70 PUSHs(err == &PL_sv_undef ? err : sv_2mortal(err));
71 }
72  
73 # Coerce a handler return into a PSGI triplet (triplet passthrough,
74 # Punk::Response, awaited Future, or JSON), folding in the context's pending
75 # status/headers. The response-finish path, in C.
76 SV *
77 # uncoverable statement
78 # uncoverable subroutine
79 _coerce(c, ret)
80 SV *c
81 SV *ret
82 CODE:
83 0 RETVAL = punk_coerce(aTHX_ c, ret); /* # uncoverable statement */
84 OUTPUT:
85 RETVAL
86  
87 # Finish a response: coerce if needed, run the after-dispatch hooks (each may
88 # replace the triplet), blank the body on HEAD.
89 SV *
90 # uncoverable statement
91 # uncoverable subroutine
92 _deliver(c, resp, method, after)
93 SV *c
94 SV *resp
95 SV *method
96 SV *after
97 CODE:
98 {
99 STRLEN ml;
100 0 const char *m = SvPV_const(method, ml); /* # uncoverable statement */
101 0 ▶ # uncoverable statement
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable statement 0 0 0
# uncoverable statement 0 0 0
102 0 ▶ # uncoverable condition left count:1
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable condition left count:1 0 0 0
103 0 ▶ # uncoverable condition right count:1
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable condition right count:1 0 0 0
104 0 # uncoverable condition left count:2
105 # uncoverable condition right count:2
106 int is_head = (ml == 4 && memEQ(m, "HEAD", 4));
107 AV *after_av = (SvROK(after) && SvTYPE(SvRV(after)) == SVt_PVAV) /* # uncoverable statement */
108 ? (AV *)SvRV(after) : NULL; /* # uncoverable statement */
109 RETVAL = punk_deliver(aTHX_ c, resp, is_head, after_av); /* # uncoverable statement */
110 }
111 OUTPUT:
112 RETVAL
« xs/serve.xs ↑ Summary xs/url.xs »