| 1 |
|
| MODULE = Punk PACKAGE = Punk |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| # The request dispatcher (punk_serve.h). compile() freezes the routing state |
| 6 |
|
| # and returns sub { Punk::_serve($state, $env) }: static/dynamic routing, the |
| 7 |
|
| # API-mount route+dispatch, PSGI mounts, 404/405, and for a web route the |
| 8 |
|
| # before hooks, guards, controller (or websocket upgrade) and response finish - |
| 9 |
|
| # all in C. Only the hooks/guards/controllers/mounts are Perl frames. |
| 10 |
|
| SV * |
| 11 |
|
| _serve(state, env) |
| 12 |
|
| SV *state |
| 13 |
|
| SV *env |
| 14 |
|
| CODE: |
| 15 |
|
| { |
| 16 |
0 |
▶ | if (!SvROK(state) || SvTYPE(SvRV(state)) != SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(state) || SvTYPE(SvRV(state)) != SVt_PVHV) |
0 |
0 |
0 |
| if (!SvROK(state) || SvTYPE(SvRV(state)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 17 |
0 |
| croak("Punk::_serve: state must be a hashref"); |
| 18 |
0 |
▶ | if (!SvROK(env) || SvTYPE(SvRV(env)) != SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(env) || SvTYPE(SvRV(env)) != SVt_PVHV) |
0 |
0 |
0 |
| if (!SvROK(env) || SvTYPE(SvRV(env)) != SVt_PVHV) |
0 |
0 |
0 |
|
| 19 |
0 |
| croak("Punk::_serve: env must be a hashref"); |
| 20 |
|
| { /* the struct the app closure carries, built for this one call */ |
| 21 |
0 |
| SV *holder = sv_2mortal(pk_state_build(aTHX_ (HV *)SvRV(state))); |
| 22 |
0 |
| RETVAL = punk_serve(aTHX_ pk_state_of(aTHX_ holder), (HV *)SvRV(env)); |
| 23 |
|
| } |
| 24 |
|
| } |
| 25 |
|
| OUTPUT: |
| 26 |
|
| RETVAL |