56 people like it.

Composable WCF Web API using Async

A functional wrapper around the new WCF Web APIs (http://wcf.codeplex.com/). Composition is achieved through the use of the HttpRequestMessage -> Async signature. Pushing the app calls in the MessageHandler intercepts all requests and allows you to take control at the earliest point possible before operation selection occurs. Extending this slightly to call the innerChannel's SendAsync would allow you to create a middleware layer that would work both with this and other, normal Web API services.

The wrapper type declarations

  1: 
  2: 
  3: 
  4: 
  5: 
  6: 
  7: 
  8: 
  9: 
 10: 
 11: 
 12: 
 13: 
 14: 
 15: 
 16: 
 17: 
 18: 
 19: 
 20: 
 21: 
 22: 
 23: 
 24: 
 25: 
 26: 
 27: 
 28: 
 29: 
 30: 
 31: 
 32: 
 33: 
 34: 
 35: 
 36: 
 37: 
 38: 
 39: 
 40: 
 41: 
 42: 
 43: 
 44: 
 45: 
 46: 
 47: 
 48: 
 49: 
 50: 
 51: 
 52: 
 53: 
 54: 
 55: 
 56: 
 57: 
 58: 
 59: 
 60: 
 61: 
 62: 
 63: 
 64: 
 65: 
 66: 
 67: 
 68: 
 69: 
 70: 
 71: 
 72: 
 73: 
 74: 
 75: 
 76: 
 77: 
 78: 
 79: 
 80: 
 81: 
 82: 
 83: 
 84: 
 85: 
 86: 
 87: 
 88: 
 89: 
 90: 
 91: 
 92: 
 93: 
 94: 
 95: 
 96: 
 97: 
 98: 
 99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
124: 
125: 
126: 
127: 
128: 
129: 
130: 
131: 
132: 
133: 
134: 
135: 
namespace FSharp.Http
open System
open System.Collections.Generic
open System.Net
open System.Net.Http
open System.ServiceModel
open System.ServiceModel.Web

// NOTE: This is not the actual OWIN definition of an application, just a close approximation.
type Application = Action<HttpRequestMessage, Action<string, seq<KeyValuePair<string,string>>, seq<obj>>, Action<exn>>
module Owin =
  let fromAsync (app:HttpRequestMessage -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>) : Application =
    Action<_,_,_>(fun request (onCompleted:Action<string, seq<KeyValuePair<string,string>>, seq<obj>>) (onError:Action<exn>) ->
      Async.StartWithContinuations(app request, onCompleted.Invoke, onError.Invoke, onError.Invoke))

/// <summary>Creates a new instance of <see cref="Processor"/>.</summary>
/// <param name="onExecute">The function to execute in the pipeline.</param>
/// <param name="onGetInArgs">Gets the incoming arguments.</param>
/// <param name="onGetOutArgs">Gets the outgoing arguments.</param>
/// <param name="onError">The action to take in the event of a processor error.</param>
/// <remarks>
/// This subclass of <see cref="System.ServiceModel.Dispatcher.Processor"/> allows
/// the developer to create <see cref="System.ServiceModel.Dispatcher.Processor"/>s
/// using higher-order functions.
/// </remarks> 
type Processor(onExecute, ?onGetInArgs, ?onGetOutArgs, ?onError) =
  inherit System.ServiceModel.Dispatcher.Processor()
  let onGetInArgs' = defaultArg onGetInArgs (fun () -> null)
  let onGetOutArgs' = defaultArg onGetOutArgs (fun () -> null)
  let onError' = defaultArg onError ignore

  override this.OnGetInArguments() = onGetInArgs'()
  override this.OnGetOutArguments() = onGetOutArgs'()
  override this.OnExecute(input) = onExecute input
  override this.OnError(result) = onError' result

/// <summary>Creates a new instance of <see cref="FuncConfiguration"/>.</summary>
/// <param name="requestProcessors">The processors to run when receiving the request.</param>
/// <param name="responseProcessors">The processors to run when sending the response.</param>
type FuncConfiguration(?requestProcessors, ?responseProcessors) =
  inherit Microsoft.ServiceModel.Http.HttpHostConfiguration()
  // Set the default values on the optional parameters.
  let requestProcessors' = defaultArg requestProcessors Seq.empty
  let responseProcessors' = defaultArg responseProcessors Seq.empty

  // Allows partial application of args to a function using function composition.
  let create args f = f args

  interface Microsoft.ServiceModel.Description.IProcessorProvider with
    member this.RegisterRequestProcessorsForOperation(operation, processors, mode) =
      requestProcessors' |> Seq.iter (processors.Add << (create operation))
  
    member this.RegisterResponseProcessorsForOperation(operation, processors, mode) =
      responseProcessors' |> Seq.iter (processors.Add << (create operation))

/// <summary>Creates a new instance of <see cref="AppResource"/>.</summary>
/// <param name="app">The application to invoke.</param>
/// <remarks>The <see cref="AppResource"/> serves as a catch-all handler for WCF HTTP services.</remarks>
[<ServiceContract>]
[<ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)>]
type AppResource(app:Application) =
  let matchStatus (status:string) =
    let statusParts = status.Split(' ')
    let statusCode = statusParts.[0]
    Enum.Parse(typeof<HttpStatusCode>, statusCode) :?> HttpStatusCode

  let handle (request:HttpRequestMessage) (response:HttpResponseMessage) =
    app.Invoke(request,
      Action<_,_,_>(fun status headers body ->
        response.StatusCode <- matchStatus status
        response.Headers.Clear()
        headers |> Seq.iter (fun (KeyValue(k,v)) -> response.Headers.Add(k,v))
        response.Content <- new ByteArrayContent(body |> Seq.map (fun o -> o :?> byte) |> Array.ofSeq)),
      Action<_>(fun e -> Console.WriteLine(e)))


  /// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
  /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
  /// <returns>The <see cref="HttpResponseMessage"/>.</returns>
  /// <remarks>Would like to merge this with the Invoke method, below.</remarks>
  [<OperationContract>]
  [<WebGet(UriTemplate="*")>]
  member x.Get(request, response:HttpResponseMessage) = handle request response

  /// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
  /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
  /// <returns>The <see cref="HttpResponseMessage"/>.</returns>
  [<OperationContract>]
  [<WebInvoke(UriTemplate="*", Method="POST")>]
  member x.Post(request, response:HttpResponseMessage) = handle request response

  /// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
  /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
  /// <returns>The <see cref="HttpResponseMessage"/>.</returns>
  [<OperationContract>]
  [<WebInvoke(UriTemplate="*", Method="PUT")>]
  member x.Put(request, response:HttpResponseMessage) = handle request response

  /// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
  /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
  /// <returns>The <see cref="HttpResponseMessage"/>.</returns>
  [<OperationContract>]
  [<WebInvoke(UriTemplate="*", Method="DELETE")>]
  member x.Delete(request, response:HttpResponseMessage) = handle request response

  /// <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
  /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
  /// <returns>The <see cref="HttpResponseMessage"/>.</returns>
  [<OperationContract>]
  [<WebInvoke(UriTemplate="*", Method="*")>]
  member x.Invoke(request, response:HttpResponseMessage) = handle request response

/// <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
/// <param name="app">The application to invoke.</param>
/// <param name="requestProcessors">The processors to run when receiving the request.</param>
/// <param name="responseProcessors">The processors to run when sending the response.</param>
/// <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>
type FuncHost(app, ?requestProcessors, ?responseProcessors, ?baseAddresses) =
  inherit System.ServiceModel.ServiceHost(AppResource(app), defaultArg baseAddresses [||])
  let requestProcessors = defaultArg requestProcessors Seq.empty
  let responseProcessors = defaultArg responseProcessors Seq.empty
  let baseUris = defaultArg baseAddresses [||]
  let config = new FuncConfiguration(requestProcessors, responseProcessors)
  do for baseUri in baseUris do
       let endpoint = base.AddServiceEndpoint(typeof<AppResource>, new HttpMessageBinding(), baseUri)
       endpoint.Behaviors.Add(new Microsoft.ServiceModel.Description.HttpEndpointBehavior(config))

  /// <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
  /// <param name="app">The application to invoke.</param>
  /// <param name="requestProcessors">The processors to run when receiving the request.</param>
  /// <param name="responseProcessors">The processors to run when sending the response.</param>
  /// <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>
  new (app: HttpRequestMessage -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>, ?requestProcessors, ?responseProcessors, ?baseAddresses) =
    let baseUris = defaultArg baseAddresses [||] |> Array.map (fun baseAddress -> Uri(baseAddress))
    new FuncHost(Owin.fromAsync app, ?requestProcessors = requestProcessors, ?responseProcessors = responseProcessors, baseAddresses = baseUris)

Sample application

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
module Main
open System
open System.Collections.Generic
open System.Net
open System.Net.Http
open Microsoft.ServiceModel.Http
open FSharp.Http

let baseurl = "http://localhost:1000/"
let processors = [| (fun op -> new PlainTextProcessor(op, MediaTypeProcessorMode.Response) :> System.ServiceModel.Dispatcher.Processor) |]

let app (request:HttpRequestMessage) = async {
  // do some stuff with the request
  return "200 OK", Seq.empty, "Howdy!"B |> Seq.map (fun b -> b :> obj) }

[<EntryPoint>]
let main(args) =
  let host = new FuncHost(app, responseProcessors = processors, baseAddresses = [|baseurl|])
  host.Open()
    
  printfn "Host open.  Hit enter to exit..."
  printfn "Use a web browser and go to %sroot or do it right and get fiddler!" baseurl
    
  System.Console.Read() |> ignore
  host.Close()
  0
namespace Microsoft.FSharp
namespace System
namespace System.Collections
namespace System.Collections.Generic
namespace System.Net
namespace System.Web
type Application = obj

Full name: FSharp.Http.Application
Multiple items
type Action =
  delegate of unit -> unit

Full name: System.Action

--------------------
type Action<'T> =
  delegate of 'T -> unit

Full name: System.Action<_>

--------------------
type Action<'T1,'T2> =
  delegate of 'T1 * 'T2 -> unit

Full name: System.Action<_,_>

--------------------
type Action<'T1,'T2,'T3> =
  delegate of 'T1 * 'T2 * 'T3 -> unit

Full name: System.Action<_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 -> unit

Full name: System.Action<_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> unit

Full name: System.Action<_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> unit

Full name: System.Action<_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> unit

Full name: System.Action<_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>

--------------------
type Action<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16> =
  delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> unit

Full name: System.Action<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = String

Full name: Microsoft.FSharp.Core.string
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
Multiple items
type KeyValuePair<'TKey,'TValue> =
  struct
    new : key:'TKey * value:'TValue -> KeyValuePair<'TKey, 'TValue>
    member Key : 'TKey
    member ToString : unit -> string
    member Value : 'TValue
  end

Full name: System.Collections.Generic.KeyValuePair<_,_>

--------------------
KeyValuePair()
KeyValuePair(key: 'TKey, value: 'TValue) : unit
type obj = Object

Full name: Microsoft.FSharp.Core.obj
type exn = Exception

Full name: Microsoft.FSharp.Core.exn
val fromAsync : app:('a -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>) -> Application

Full name: FSharp.Http.Owin.fromAsync
val app : ('a -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>)
Multiple items
type Async
static member AsBeginEnd : computation:('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit)
static member AwaitEvent : event:IEvent<'Del,'T> * ?cancelAction:(unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate)
static member AwaitIAsyncResult : iar:IAsyncResult * ?millisecondsTimeout:int -> Async<bool>
static member AwaitTask : task:Task<'T> -> Async<'T>
static member AwaitWaitHandle : waitHandle:WaitHandle * ?millisecondsTimeout:int -> Async<bool>
static member CancelDefaultToken : unit -> unit
static member Catch : computation:Async<'T> -> Async<Choice<'T,exn>>
static member FromBeginEnd : beginAction:(AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg:'Arg1 * beginAction:('Arg1 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * beginAction:('Arg1 * 'Arg2 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromBeginEnd : arg1:'Arg1 * arg2:'Arg2 * arg3:'Arg3 * beginAction:('Arg1 * 'Arg2 * 'Arg3 * AsyncCallback * obj -> IAsyncResult) * endAction:(IAsyncResult -> 'T) * ?cancelAction:(unit -> unit) -> Async<'T>
static member FromContinuations : callback:(('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T>
static member Ignore : computation:Async<'T> -> Async<unit>
static member OnCancel : interruption:(unit -> unit) -> Async<IDisposable>
static member Parallel : computations:seq<Async<'T>> -> Async<'T []>
static member RunSynchronously : computation:Async<'T> * ?timeout:int * ?cancellationToken:CancellationToken -> 'T
static member Sleep : millisecondsDueTime:int -> Async<unit>
static member Start : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions * ?cancellationToken:CancellationToken -> Task<'T>
static member StartChild : computation:Async<'T> * ?millisecondsTimeout:int -> Async<Async<'T>>
static member StartChildAsTask : computation:Async<'T> * ?taskCreationOptions:TaskCreationOptions -> Async<Task<'T>>
static member StartImmediate : computation:Async<unit> * ?cancellationToken:CancellationToken -> unit
static member StartWithContinuations : computation:Async<'T> * continuation:('T -> unit) * exceptionContinuation:(exn -> unit) * cancellationContinuation:(OperationCanceledException -> unit) * ?cancellationToken:CancellationToken -> unit
static member SwitchToContext : syncContext:SynchronizationContext -> Async<unit>
static member SwitchToNewThread : unit -> Async<unit>
static member SwitchToThreadPool : unit -> Async<unit>
static member TryCancelled : computation:Async<'T> * compensation:(OperationCanceledException -> unit) -> Async<'T>
static member CancellationToken : Async<CancellationToken>
static member DefaultCancellationToken : CancellationToken

Full name: Microsoft.FSharp.Control.Async

--------------------
type Async<'T>

Full name: Microsoft.FSharp.Control.Async<_>
static member Async.StartWithContinuations : computation:Async<'T> * continuation:('T -> unit) * exceptionContinuation:(exn -> unit) * cancellationContinuation:(OperationCanceledException -> unit) * ?cancellationToken:Threading.CancellationToken -> unit
Multiple items
type Processor =
  inherit obj
  new : onExecute:'a * ?onGetInArgs:'b * ?onGetOutArgs:'c * ?onError:'d -> Processor
  override OnError : result:'a -> 'b
  override OnExecute : input:'a -> 'b
  override OnGetInArguments : unit -> 'a
  override OnGetOutArguments : unit -> 'a

Full name: FSharp.Http.Processor


 <summary>Creates a new instance of <see cref="Processor"/>.</summary>
 <param name="onExecute">The function to execute in the pipeline.</param>
 <param name="onGetInArgs">Gets the incoming arguments.</param>
 <param name="onGetOutArgs">Gets the outgoing arguments.</param>
 <param name="onError">The action to take in the event of a processor error.</param>
 <remarks>
 This subclass of <see cref="System.ServiceModel.Dispatcher.Processor"/> allows
 the developer to create <see cref="System.ServiceModel.Dispatcher.Processor"/>s
 using higher-order functions.
 </remarks>


--------------------
new : onExecute:'a * ?onGetInArgs:'b * ?onGetOutArgs:'c * ?onError:'d -> Processor
val onExecute : 'a
val onGetInArgs : 'a option
val onGetOutArgs : 'a option
val onError : 'a option
val defaultArg : arg:'T option -> defaultValue:'T -> 'T

Full name: Microsoft.FSharp.Core.Operators.defaultArg
val ignore : value:'T -> unit

Full name: Microsoft.FSharp.Core.Operators.ignore
override Processor.OnGetInArguments : unit -> 'a

Full name: FSharp.Http.Processor.OnGetInArguments
override Processor.OnGetOutArguments : unit -> 'a

Full name: FSharp.Http.Processor.OnGetOutArguments
override Processor.OnExecute : input:'a -> 'b

Full name: FSharp.Http.Processor.OnExecute
override Processor.OnError : result:'a -> 'b

Full name: FSharp.Http.Processor.OnError
Multiple items
type FuncConfiguration =
  inherit obj
  interface obj
  new : ?requestProcessors:'a * ?responseProcessors:'b -> FuncConfiguration
  override RegisterRequestProcessorsForOperation : operation:'a * processors:'b * mode:'c -> 'd
  override RegisterResponseProcessorsForOperation : operation:'a * processors:'b * mode:'c -> 'd

Full name: FSharp.Http.FuncConfiguration


 <summary>Creates a new instance of <see cref="FuncConfiguration"/>.</summary>
 <param name="requestProcessors">The processors to run when receiving the request.</param>
 <param name="responseProcessors">The processors to run when sending the response.</param>


--------------------
new : ?requestProcessors:'a * ?responseProcessors:'b -> FuncConfiguration
val requestProcessors : 'a option
val responseProcessors : 'a option
namespace Microsoft
module Seq

from Microsoft.FSharp.Collections
val empty<'T> : seq<'T>

Full name: Microsoft.FSharp.Collections.Seq.empty
override FuncConfiguration.RegisterRequestProcessorsForOperation : operation:'a * processors:'b * mode:'c -> 'd

Full name: FSharp.Http.FuncConfiguration.RegisterRequestProcessorsForOperation
val iter : action:('T -> unit) -> source:seq<'T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iter
override FuncConfiguration.RegisterResponseProcessorsForOperation : operation:'a * processors:'b * mode:'c -> 'd

Full name: FSharp.Http.FuncConfiguration.RegisterResponseProcessorsForOperation
type Single =
  struct
    member CompareTo : value:obj -> int + 1 overload
    member Equals : obj:obj -> bool + 1 overload
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> TypeCode
    member ToString : unit -> string + 3 overloads
    static val MinValue : float32
    static val Epsilon : float32
    static val MaxValue : float32
    static val PositiveInfinity : float32
    static val NegativeInfinity : float32
    ...
  end

Full name: System.Single
Multiple items
type AppResource =
  new : app:Application -> AppResource
  member Delete : request:'d * response:'e -> 'f
  member Get : request:'m * response:'n -> 'o
  member Invoke : request:'a * response:'b -> 'c
  member Post : request:'j * response:'k -> 'l
  member Put : request:'g * response:'h -> 'i

Full name: FSharp.Http.AppResource


 <summary>Creates a new instance of <see cref="AppResource"/>.</summary>
 <param name="app">The application to invoke.</param>
 <remarks>The <see cref="AppResource"/> serves as a catch-all handler for WCF HTTP services.</remarks>


--------------------
new : app:Application -> AppResource
val app : Application
val matchStatus : (string -> HttpStatusCode)
val status : string
val statusParts : string []
String.Split([<ParamArray>] separator: char []) : string []
String.Split(separator: string [], options: StringSplitOptions) : string []
String.Split(separator: char [], options: StringSplitOptions) : string []
String.Split(separator: char [], count: int) : string []
String.Split(separator: string [], count: int, options: StringSplitOptions) : string []
String.Split(separator: char [], count: int, options: StringSplitOptions) : string []
val statusCode : string
type Enum =
  member CompareTo : target:obj -> int
  member Equals : obj:obj -> bool
  member GetHashCode : unit -> int
  member GetTypeCode : unit -> TypeCode
  member HasFlag : flag:Enum -> bool
  member ToString : unit -> string + 3 overloads
  static member Format : enumType:Type * value:obj * format:string -> string
  static member GetName : enumType:Type * value:obj -> string
  static member GetNames : enumType:Type -> string[]
  static member GetUnderlyingType : enumType:Type -> Type
  ...

Full name: System.Enum
Enum.Parse(enumType: Type, value: string) : obj
Enum.Parse(enumType: Type, value: string, ignoreCase: bool) : obj
val typeof<'T> : Type

Full name: Microsoft.FSharp.Core.Operators.typeof
type HttpStatusCode =
  | Continue = 100
  | SwitchingProtocols = 101
  | OK = 200
  | Created = 201
  | Accepted = 202
  | NonAuthoritativeInformation = 203
  | NoContent = 204
  | ResetContent = 205
  | PartialContent = 206
  | MultipleChoices = 300
  ...

Full name: System.Net.HttpStatusCode
val handle : ('a -> 'b -> 'c)
val request : 'a
val response : 'b
active recognizer KeyValue: KeyValuePair<'Key,'Value> -> 'Key * 'Value

Full name: Microsoft.FSharp.Core.Operators.( |KeyValue| )
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
Multiple items
val byte : value:'T -> byte (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.byte

--------------------
type byte = Byte

Full name: Microsoft.FSharp.Core.byte
type Array =
  member Clone : unit -> obj
  member CopyTo : array:Array * index:int -> unit + 1 overload
  member GetEnumerator : unit -> IEnumerator
  member GetLength : dimension:int -> int
  member GetLongLength : dimension:int -> int64
  member GetLowerBound : dimension:int -> int
  member GetUpperBound : dimension:int -> int
  member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
  member Initialize : unit -> unit
  member IsFixedSize : bool
  ...

Full name: System.Array
val ofSeq : source:seq<'T> -> 'T []

Full name: Microsoft.FSharp.Collections.Array.ofSeq
type Console =
  static member BackgroundColor : ConsoleColor with get, set
  static member Beep : unit -> unit + 1 overload
  static member BufferHeight : int with get, set
  static member BufferWidth : int with get, set
  static member CapsLock : bool
  static member Clear : unit -> unit
  static member CursorLeft : int with get, set
  static member CursorSize : int with get, set
  static member CursorTop : int with get, set
  static member CursorVisible : bool with get, set
  ...

Full name: System.Console
Console.WriteLine() : unit
   (+0 other overloads)
Console.WriteLine(value: string) : unit
   (+0 other overloads)
Console.WriteLine(value: obj) : unit
   (+0 other overloads)
Console.WriteLine(value: uint64) : unit
   (+0 other overloads)
Console.WriteLine(value: int64) : unit
   (+0 other overloads)
Console.WriteLine(value: uint32) : unit
   (+0 other overloads)
Console.WriteLine(value: int) : unit
   (+0 other overloads)
Console.WriteLine(value: float32) : unit
   (+0 other overloads)
Console.WriteLine(value: float) : unit
   (+0 other overloads)
Console.WriteLine(value: decimal) : unit
   (+0 other overloads)
val x : AppResource
member AppResource.Get : request:'m * response:'n -> 'o

Full name: FSharp.Http.AppResource.Get


 <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
 <param name="request">The <see cref="HttpRequestMessage"/>.</param>
 <returns>The <see cref="HttpResponseMessage"/>.</returns>
 <remarks>Would like to merge this with the Invoke method, below.</remarks>
val request : 'm
val response : 'n
member AppResource.Post : request:'j * response:'k -> 'l

Full name: FSharp.Http.AppResource.Post


 <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
 <param name="request">The <see cref="HttpRequestMessage"/>.</param>
 <returns>The <see cref="HttpResponseMessage"/>.</returns>
val request : 'j
val response : 'k
member AppResource.Put : request:'g * response:'h -> 'i

Full name: FSharp.Http.AppResource.Put


 <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
 <param name="request">The <see cref="HttpRequestMessage"/>.</param>
 <returns>The <see cref="HttpResponseMessage"/>.</returns>
val request : 'g
val response : 'h
member AppResource.Delete : request:'d * response:'e -> 'f

Full name: FSharp.Http.AppResource.Delete


 <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
 <param name="request">The <see cref="HttpRequestMessage"/>.</param>
 <returns>The <see cref="HttpResponseMessage"/>.</returns>
val request : 'd
val response : 'e
member AppResource.Invoke : request:'a * response:'b -> 'c

Full name: FSharp.Http.AppResource.Invoke


 <summary>Invokes the application with the specified GET <paramref name="request"/>.</summary>
 <param name="request">The <see cref="HttpRequestMessage"/>.</param>
 <returns>The <see cref="HttpResponseMessage"/>.</returns>
Multiple items
type FuncHost =
  inherit obj
  new : app:'a * ?requestProcessors:'b * ?responseProcessors:'c * ?baseAddresses:'d -> FuncHost
  new : app:('a -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>) * ?requestProcessors:'b * ?responseProcessors:'c * ?baseAddresses:'d -> FuncHost

Full name: FSharp.Http.FuncHost


 <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
 <param name="app">The application to invoke.</param>
 <param name="requestProcessors">The processors to run when receiving the request.</param>
 <param name="responseProcessors">The processors to run when sending the response.</param>
 <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>


--------------------
new : app:('a -> Async<string * seq<KeyValuePair<string,string>> * seq<obj>>) * ?requestProcessors:'b * ?responseProcessors:'c * ?baseAddresses:'d -> FuncHost


 <summary>Creates a new instance of <see cref="FuncHost"/>.</summary>
 <param name="app">The application to invoke.</param>
 <param name="requestProcessors">The processors to run when receiving the request.</param>
 <param name="responseProcessors">The processors to run when sending the response.</param>
 <param name="baseAddresses">The base addresses to host (defaults to an empty array).</param>

new : app:'a * ?requestProcessors:'b * ?responseProcessors:'c * ?baseAddresses:'d -> FuncHost
val app : 'a
val baseAddresses : 'a option
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []

Full name: Microsoft.FSharp.Collections.Array.map
Multiple items
type Uri =
  new : uriString:string -> Uri + 5 overloads
  member AbsolutePath : string
  member AbsoluteUri : string
  member Authority : string
  member DnsSafeHost : string
  member Equals : comparand:obj -> bool
  member Fragment : string
  member GetComponents : components:UriComponents * format:UriFormat -> string
  member GetHashCode : unit -> int
  member GetLeftPart : part:UriPartial -> string
  ...

Full name: System.Uri

--------------------
Uri(uriString: string) : unit
Uri(uriString: string, uriKind: UriKind) : unit
Uri(baseUri: Uri, relativeUri: string) : unit
Uri(baseUri: Uri, relativeUri: Uri) : unit
module Owin

from FSharp.Http
val async : AsyncBuilder

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.async
Multiple items
type EntryPointAttribute =
  inherit Attribute
  new : unit -> EntryPointAttribute

Full name: Microsoft.FSharp.Core.EntryPointAttribute

--------------------
new : unit -> EntryPointAttribute
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Console.Read() : int

More information

Link:http://fssnip.net/2f
Posted:13 years ago
Author:Ryan Riley
Tags: async , wcf , wcf web api , web