Skip to content

Commit

Permalink
[Giraffe] Add utilities for WebPart
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Feb 15, 2024
1 parent c5b842b commit 7cb306e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Aardvark.Service.Giraffe/Giraffe.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@ open Microsoft.Extensions.Logging
open Microsoft.Extensions.DependencyInjection
open Microsoft.AspNetCore.Http
open System.Threading
open System.Reflection
open System.Net
open Giraffe

type WebPart = HttpFunc -> HttpContext -> HttpFuncResult

module WebPart =
open Aardvark.Service.Giraffe

let ofAssembly (assembly: Assembly) : WebPart =
Reflection.assemblyWebPart assembly

let ofRouteHtml (route: string) (handler: (string -> string option) -> string) : WebPart =
let handle (next: HttpFunc) (ctx: HttpContext) =
let response = handler ctx.TryGetQueryStringValue
htmlString response next ctx

Giraffe.Routing.route route >=> handle

module Server =

type WebApp = HttpFunc -> HttpContext -> HttpFuncResult
type WebApp = WebPart

let startServer' (url : string) (cancellationToken : CancellationToken) (content : WebApp list) =
let configureApp (app : IApplicationBuilder) =
Expand Down

0 comments on commit 7cb306e

Please sign in to comment.