.NET 6 #32

Merged
danieljsummers merged 3 commits from dotnet-six into main 2021-09-19 02:42:41 +00:00
2 changed files with 9 additions and 9 deletions
Showing only changes of commit 49d9030f50 - Show all commits

View File

@ -9,7 +9,7 @@ module Configure =
open Cookies
open Giraffe
open Giraffe.TokenRouter
open Giraffe.EndpointRouting
open Microsoft.AspNetCore.Localization
open Microsoft.AspNetCore.Server.Kestrel.Core
open Microsoft.EntityFrameworkCore
@ -49,6 +49,7 @@ module Configure =
.AddDistributedMemoryCache()
.AddSession()
.AddAntiforgery()
.AddRouting()
.AddSingleton<IClock>(SystemClock.Instance)
|> ignore
let config = svc.BuildServiceProvider().GetRequiredService<IConfiguration>()
@ -60,11 +61,9 @@ module Configure =
|> ignore
/// Routes for PrayerTracker
let webApp =
router Handlers.CommonFunctions.fourOhFour [
// Traditional web app routes
subRoute"/web" [
GET [
let routes =
[ subRoute "/web" [
GET_HEAD [
subRoute "/church" [
route "es" Handlers.Church.maintain
routef "/%O/edit" Handlers.Church.edit
@ -144,7 +143,8 @@ module Configure =
// Temp redirect to new URLs
route "/" (redirectTo false "/web/")
]
/// Giraffe error handler
let errorHandler (ex : exn) (logger : ILogger) =
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
clearResponse >=> setStatusCode 500 >=> text ex.Message
@ -171,9 +171,10 @@ module Configure =
app.UseGiraffeErrorHandler errorHandler)
.UseStatusCodePagesWithReExecute("/error/{0}")
.UseStaticFiles()
.UseRouting()
.UseSession()
.UseRequestLocalization(app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>().Value)
.UseGiraffe(webApp)
.UseEndpoints (fun e -> e.MapGiraffeEndpoints routes)
|> ignore
Views.I18N.setUpFactories <| app.ApplicationServices.GetRequiredService<IStringLocalizerFactory> ()

View File

@ -24,7 +24,6 @@
<ItemGroup>
<PackageReference Include="Giraffe" Version="5.0.0" />
<PackageReference Include="Giraffe.TokenRouter" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
</ItemGroup>