Convert routes to endpoints (#31)
This commit is contained in:
		
							parent
							
								
									7a2f2bd92d
								
							
						
					
					
						commit
						49d9030f50
					
				@ -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> ()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user