11namespace FSharp.Data.GraphQL.Samples.StarWarsApi
22
33open Microsoft.AspNetCore .Builder
4+ open Microsoft.AspNetCore .Http
5+ open Microsoft.AspNetCore .Server .Kestrel .Core
46open Microsoft.Extensions .Configuration
57open Microsoft.Extensions .DependencyInjection
6- open Giraffe
8+ open Microsoft. Extensions . Hosting
79open Microsoft.Extensions .Logging
10+ open Giraffe
811open System
9- open Microsoft.AspNetCore .Server .Kestrel .Core
1012
1113type Startup private () =
1214 new ( configuration : IConfiguration ) as this =
@@ -19,10 +21,17 @@ type Startup private () =
1921 .Configure( Action< IISServerOptions>( fun x -> x.AllowSynchronousIO <- true ))
2022 |> ignore
2123
22- member _.Configure ( app : IApplicationBuilder ) =
24+ member _.Configure ( app : IApplicationBuilder , env : IHostEnvironment ) =
2325 let errorHandler ( ex : Exception ) ( log : ILogger ) =
2426 log.LogError( EventId(), ex, " An unhandled exception has occurred while executing the request." )
2527 clearResponse >=> setStatusCode 500
28+
29+ if env.IsDevelopment() then
30+ app.UseGraphQLPlayground( " /playground" ) |> ignore
31+ app.UseGraphQLVoyager( " /voyager" ) |> ignore
32+ app.UseRouting() |> ignore
33+ app.UseEndpoints( fun endpoints -> endpoints.MapBananaCakePop( PathString( " /cakePop" )) |> ignore) |> ignore
34+
2635 app
2736 .UseGiraffeErrorHandler( errorHandler)
2837 .UseWebSockets()
0 commit comments