<?php

namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use App\Filesystem\HttpGoAdapter;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Storage::extend('http_go', function($app, $config) {
            $adapter = new HttpGoAdapter($config['base_uri']);
            $filesystem = new Filesystem($adapter);
            // 直接返回 FilesystemAdapter 并传入 config，确保 url() 方法能读取配置
            return new \Illuminate\Filesystem\FilesystemAdapter($filesystem, $config);
        });
    }
}
