Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Http/Middleware/AddLinkHeadersForPreloadedAssets.php
Строк: 49
<?php

namespace IlluminateHttpMiddleware;

use 
IlluminateHttpResponse;
use 
IlluminateSupportCollection;
use 
IlluminateSupportFacadesVite;

class 
AddLinkHeadersForPreloadedAssets
{
    
/**
     * Configure the middleware.
     *
     * @param  int  $limit
     * @return string
     */
    
public static function using($limit)
    {
        return static::class.
':'.$limit;
    }

    
/**
     * Handle the incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @param  int|null  $limit
     * @return IlluminateHttpResponse
     */
    
public function handle($request$next$limit null)
    {
        return 
tap($next($request), function ($response) use ($limit) {
            if (
$response instanceof Response && Vite::preloadedAssets() !== []) {
                
$response->header('Link', (new Collection(Vite::preloadedAssets()))
                    ->
when($limitfn ($assets$limit) => $assets->take($limit))
                    ->
map(fn ($attributes$url) => "<{$url}>; ".implode('; '$attributes))
                    ->
join(', '), false);
            }
        });
    }
}
Онлайн: 2
Реклама