Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Created July 10, 2014 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panesofglass/7cd866c669023d23e014 to your computer and use it in GitHub Desktop.
Save panesofglass/7cd866c669023d23e014 to your computer and use it in GitHub Desktop.
Taliesin Sample
namespace FSharpWeb4
open Owin
open Microsoft.Owin
open System
open System.Net
open System.Net.Http
open System.Web
open Dyfrig
open Taliesin
type Resources = Home
with
interface IUriRouteTemplate with
member x.UriTemplate = "/"
module App =
let makeHttpHandler statusCode (data: byte[]) =
let handler (request: HttpRequestMessage) =
let content = new ByteArrayContent(data)
content.Headers.ContentLength <- Nullable data.LongLength
content.Headers.ContentType <- Headers.MediaTypeHeaderValue("text/plain")
new HttpResponseMessage(statusCode, Content = content, RequestMessage = request)
|> async.Return
Dyfrig.SystemNetHttpAdapter.fromAsyncSystemNetHttp handler
let spec = RouteLeaf(Home, [GET(makeHttpHandler HttpStatusCode.OK "Hello from Taliesin!"B)])
type Startup() =
member x.Configuration(app: IAppBuilder) =
let taliesin = new ResourceManager<Resources>()
let subscription = taliesin.Start(App.spec)
app.Use(fun _ -> taliesin.Invoke) |> ignore
type Global() =
inherit System.Web.HttpApplication()
[<assembly:OwinStartup(typeof<Startup>)>]
do ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment