.NET 6 #32
@ -9,7 +9,7 @@ module Configure =
|
|||||||
|
|
||||||
open Cookies
|
open Cookies
|
||||||
open Giraffe
|
open Giraffe
|
||||||
open Giraffe.TokenRouter
|
open Giraffe.EndpointRouting
|
||||||
open Microsoft.AspNetCore.Localization
|
open Microsoft.AspNetCore.Localization
|
||||||
open Microsoft.AspNetCore.Server.Kestrel.Core
|
open Microsoft.AspNetCore.Server.Kestrel.Core
|
||||||
open Microsoft.EntityFrameworkCore
|
open Microsoft.EntityFrameworkCore
|
||||||
@ -49,6 +49,7 @@ module Configure =
|
|||||||
.AddDistributedMemoryCache()
|
.AddDistributedMemoryCache()
|
||||||
.AddSession()
|
.AddSession()
|
||||||
.AddAntiforgery()
|
.AddAntiforgery()
|
||||||
|
.AddRouting()
|
||||||
.AddSingleton<IClock>(SystemClock.Instance)
|
.AddSingleton<IClock>(SystemClock.Instance)
|
||||||
|> ignore
|
|> ignore
|
||||||
let config = svc.BuildServiceProvider().GetRequiredService<IConfiguration>()
|
let config = svc.BuildServiceProvider().GetRequiredService<IConfiguration>()
|
||||||
@ -60,11 +61,9 @@ module Configure =
|
|||||||
|> ignore
|
|> ignore
|
||||||
|
|
||||||
/// Routes for PrayerTracker
|
/// Routes for PrayerTracker
|
||||||
let webApp =
|
let routes =
|
||||||
router Handlers.CommonFunctions.fourOhFour [
|
[ subRoute "/web" [
|
||||||
// Traditional web app routes
|
GET_HEAD [
|
||||||
subRoute"/web" [
|
|
||||||
GET [
|
|
||||||
subRoute "/church" [
|
subRoute "/church" [
|
||||||
route "es" Handlers.Church.maintain
|
route "es" Handlers.Church.maintain
|
||||||
routef "/%O/edit" Handlers.Church.edit
|
routef "/%O/edit" Handlers.Church.edit
|
||||||
@ -145,6 +144,7 @@ module Configure =
|
|||||||
route "/" (redirectTo false "/web/")
|
route "/" (redirectTo false "/web/")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/// Giraffe error handler
|
||||||
let errorHandler (ex : exn) (logger : ILogger) =
|
let errorHandler (ex : exn) (logger : ILogger) =
|
||||||
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
|
logger.LogError(EventId(), ex, "An unhandled exception has occurred while executing the request.")
|
||||||
clearResponse >=> setStatusCode 500 >=> text ex.Message
|
clearResponse >=> setStatusCode 500 >=> text ex.Message
|
||||||
@ -171,9 +171,10 @@ module Configure =
|
|||||||
app.UseGiraffeErrorHandler errorHandler)
|
app.UseGiraffeErrorHandler errorHandler)
|
||||||
.UseStatusCodePagesWithReExecute("/error/{0}")
|
.UseStatusCodePagesWithReExecute("/error/{0}")
|
||||||
.UseStaticFiles()
|
.UseStaticFiles()
|
||||||
|
.UseRouting()
|
||||||
.UseSession()
|
.UseSession()
|
||||||
.UseRequestLocalization(app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>().Value)
|
.UseRequestLocalization(app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>().Value)
|
||||||
.UseGiraffe(webApp)
|
.UseEndpoints (fun e -> e.MapGiraffeEndpoints routes)
|
||||||
|> ignore
|
|> ignore
|
||||||
Views.I18N.setUpFactories <| app.ApplicationServices.GetRequiredService<IStringLocalizerFactory> ()
|
Views.I18N.setUpFactories <| app.ApplicationServices.GetRequiredService<IStringLocalizerFactory> ()
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Giraffe" Version="5.0.0" />
|
<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="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user