Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frameworks/mark/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN apt-get install -yqq php8.5-cli php8.5-xml php8.5-zip php8.5-pgsql >/dev/nul
COPY --from=composer/composer:latest-bin --link /composer /usr/local/bin/composer

RUN apt-get install -y php-pear php8.5-dev libevent-dev git >/dev/null && \
pecl install event-3.1.4 > /dev/null && echo "extension=event.so" > /etc/php/8.5/cli/conf.d/30-event.ini
pecl install event-3.1.4 >/dev/null && echo "extension=event.so" > /etc/php/8.5/cli/conf.d/30-event.ini && \
pecl install brotli >/dev/null && echo "extension=brotli.so" > /etc/php/8.5/cli/conf.d/30-brotli.ini

WORKDIR /mark
COPY composer.json .
Expand Down
16 changes: 14 additions & 2 deletions frameworks/mark/handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ function json($request, $count)
$total[] = $item;
}

$result = json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$header = [];
if($encoding = $request->header('accept-encoding', '')) {
if(str_contains($encoding, 'br')) {
$result = brotli_compress($result, 1);
$header = ['Content-Encoding' => 'br'];
} elseif (str_contains($encoding, 'gzip')) {
$result = gzencode($result, 1);
$header = ['Content-Encoding' => 'br'];
}
}

return new Response (
200,
['Content-Type' => 'application/json'],
json_encode(['items' => $total, 'count' => $count], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
['Content-Type' => 'application/json'] + $header,
$result
);
}

Expand Down
2 changes: 2 additions & 0 deletions frameworks/mark/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"pipelined",
"limited-conn",
"json",
"json-comp",
"noisy",
"static",
"api-4",
"api-16",
Expand Down
Loading