Skip to content
Mattias Nordqvist edited this page Nov 11, 2015 · 1 revision
open System
open WebAnchor.RequestFactory
open System.Threading.Tasks


type Planet = {
    Name:string; 
}

type IMyApi = 
    [<HttpAttributes.Get("planets/{id}")>]
    abstract Get : id:int -> Task<Planet> 

 
[<EntryPoint>]
let main argv = 
  let download = async {
    let api = WebAnchor.Api.For<IMyApi>("http://swapi.co/api/")
    let! result = Async.AwaitTask(api.Get 1)
    return result
  }

  let finalResult = Async.RunSynchronously download
  printfn "Task result is : %O" finalResult.Name
   
  Console.ReadLine() |> ignore
  0

Documentation (v6.1.0)

  1. Getting started
  2. Basics (Http GET & Base Location)
  3. Basics pt. 2 (POST/PUT/DELETE, HttpResponseMessage, Exceptions, HttpClient, IDisposable)
  4. Building an HttpRequestMessage
  5. Parameter attributes
  6. Handling responses
  7. ApiSettings
  8. Typical setup (Develop/Test/Production & Mocking)
  9. Logging
  10. Testing
  11. Generic Api
  12. Multipart
Clone this wiki locally