Lines 143-148
is raised.
Link Here
|
143 |
return $params; |
143 |
return $params; |
144 |
} |
144 |
} |
145 |
); |
145 |
); |
|
|
146 |
|
147 |
=head3 stash_embed |
148 |
|
149 |
$c->stash_embed( $c->match->endpoint->pattern->defaults->{'openapi.op_spec'} ); |
150 |
|
151 |
=cut |
152 |
|
153 |
$app->helper( |
154 |
'stash_embed' => sub { |
155 |
|
156 |
my ( $c, $spec ) = @_; |
157 |
|
158 |
my $embed_spec = $spec->{'x-koha-embed'}; |
159 |
my $embed_header = $c->req->headers->header('x-koha-embed'); |
160 |
|
161 |
Koha::Exceptions::WrongParameter->throw("Embedding objects is not allowed on this endpoint") |
162 |
if $embed_header and !defined $embed_spec; |
163 |
|
164 |
my @to_embed; |
165 |
foreach my $embed_req ( split /\s*,\s*/, $embed_header ) { |
166 |
my $matches = grep {lc $_ eq lc $embed_req} @{ $embed_req }; |
167 |
|
168 |
Koha::Exceptions::WrongParameter->throw( |
169 |
error => 'Embeding '.$embed_req. ' is not authorised. Check your x-koha-embed headers or remove it.' |
170 |
) unless $matches; |
171 |
|
172 |
push @to_embed, $embed_req; |
173 |
} |
174 |
|
175 |
$c->stash( 'koha.embed' => \@to_embed ) |
176 |
if scalar @to_embed > 0; |
177 |
|
178 |
return $c; |
179 |
} |
180 |
); |
146 |
} |
181 |
} |
147 |
|
182 |
|
148 |
=head2 Internal methods |
183 |
=head2 Internal methods |