如何从Giraffe-FSharp中的configureServices
方法内部访问配置?
以下是SAFE template通过dotnet new SAFE -lang F# --server giraffe
创建的长颈鹿设置的简略部分:
let configureServices (services : IServiceCollection) =
services.AddCors() |> ignore
services.AddGiraffe() |> ignore
// Want to access configuration here.
[<EntryPoint>]
let main _ =
let contentRoot = Directory.GetCurrentDirectory()
let webRoot = Path.Combine(contentRoot, "WebRoot")
WebHostBuilder()
.UseKestrel()
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfig)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
0
答案 0 :(得分:2)
从服务集合中获取服务提供者,然后使用它来获取配置:
Access-Control-Allow-Methods