| 1 |
|
| MODULE = Punk PACKAGE = Punk::Plugin::ConditionalGet |
| 2 |
|
| |
| 3 |
|
| PROTOTYPES: DISABLE |
| 4 |
|
| |
| 5 |
|
| # register($app, \%opts) |
| 6 |
|
| # |
| 7 |
|
| # The plugin is an on-switch and a place for the documentation to live: the |
| 8 |
|
| # work is the `etag` route option and the check in punk_cget.h, which the |
| 9 |
|
| # dispatcher runs between a route's guards and its handler. |
| 10 |
|
| # |
| 11 |
|
| # It is registered rather than always-on because the option changes what a |
| 12 |
|
| # request costs and what a client caches, and because a route option that |
| 13 |
|
| # does something only when a plugin is loaded is the arrangement `sitemap` |
| 14 |
|
| # already established. |
| 15 |
|
| void |
| 16 |
|
| register(self, app, opts = &PL_sv_undef) |
| 17 |
|
| SV *self |
| 18 |
|
| SV *app |
| 19 |
|
| SV *opts |
| 20 |
|
| CODE: |
| 21 |
|
| { |
| 22 |
20 |
| HV *h = app_hv(aTHX_ app); |
| 23 |
|
| PERL_UNUSED_VAR(self); |
| 24 |
20 |
▶ | if (SvOK(opts) && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvOK(opts) && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { |
20 |
0 |
20 |
| if (SvOK(opts) && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { |
20 |
0 |
20 |
| if (SvOK(opts) && SvROK(opts) && SvTYPE(SvRV(opts)) == SVt_PVHV) { |
20 |
0 |
20 |
|
| 25 |
20 |
| HV *o = (HV *)SvRV(opts); |
| 26 |
|
| HE *he; |
| 27 |
20 |
| hv_iterinit(o); |
| 28 |
20 |
▶ | while ((he = hv_iternext(o))) |
Branch: 1 branch
| Branch | True | False | Total |
| while ((he = hv_iternext(o))) |
1 |
19 |
20 |
|
| 29 |
1 |
▶ | croak("Punk::Plugin::ConditionalGet: unknown option '%s' - " |
Branch: 1 branch
| Branch | True | False | Total |
| croak("Punk::Plugin::ConditionalGet: unknown option '%s' - " |
0 |
1 |
1 |
|
| 30 |
|
| "there is nothing to configure here; the decision is " |
| 31 |
|
| "per route, as `etag`", HePV(he, PL_na)); |
| 32 |
|
| } |
| 33 |
19 |
| (void)hv_stores(h, K_CGET, newSViv(1)); |
| 34 |
|
| } |