<commit_before><?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Server;
use Zend\Stratigility\Http\Response as ZendResponse;
use Zend\Stratigility\MiddlewarePipe;

// Instantiate the application, register providers etc.
$app = require __DIR__.'/system/bootstrap.php';

// Build a middleware pipeline for Flarum
$flarum = new MiddlewarePipe();
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));

$api = new MiddlewarePipe();
$api->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));

$admin = new MiddlewarePipe();
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));

$flarum->pipe('/api', $api);
$flarum->pipe('/admin', $admin);
$flarum->pipe(function(Request $request, Response $response, $next) use ($app) {
	/** @var Flarum\Http\Router $router */
	$router = $app->make('Flarum\Http\Router');

	$response = new ZendResponse($router->dispatch($request));

	return $next($request, $response);
});

$server = Server::createServer(
	$flarum,
	$_SERVER,
	$_GET,<commit_msg>Apply JSON parameter middleware to all Flarum requests<commit_after><?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Diactoros\Server;
use Zend\Stratigility\Http\Response as ZendResponse;
use Zend\Stratigility\MiddlewarePipe;

// Instantiate the application, register providers etc.
$app = require __DIR__.'/system/bootstrap.php';

// Build a middleware pipeline for Flarum
$flarum = new MiddlewarePipe();
$flarum->pipe($app->make('Flarum\Forum\Middleware\LoginWithCookie'));

$api = new MiddlewarePipe();
$flarum->pipe($app->make('Flarum\Api\Middleware\ReadJsonParameters'));
$api->pipe($app->make('Flarum\Api\Middleware\LoginWithHeader'));

$admin = new MiddlewarePipe();
$admin->pipe($app->make('Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin'));

$flarum->pipe('/api', $api);
$flarum->pipe('/admin', $admin);
$flarum->pipe(function(Request $request, Response $response, $next) use ($app) {
	/** @var Flarum\Http\Router $router */
	$router = $app->make('Flarum\Http\Router');

	$response = new ZendResponse($router->dispatch($request));

	return $next($request, $response);
});

$server = Server::createServer(
	$flarum,
	$_SERVER,
	$_GET,
{'fraction_non_alphanumeric': 0.1723563696919234, 'fraction_numerical': 0.0, 'mean_word_length': 6.556603773584905, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2031392', 'n_tokens_mistral': 805, 'n_tokens_neox': 770, 'n_words': 150}