-
Notifications
You must be signed in to change notification settings - Fork 8
F# example
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
- Getting started
- Basics (Http GET & Base Location)
- Basics pt. 2 (POST/PUT/DELETE, HttpResponseMessage, Exceptions, HttpClient, IDisposable)
- Building an HttpRequestMessage
- Parameter attributes
- Handling responses
- ApiSettings
- Typical setup (Develop/Test/Production & Mocking)
- Logging
- Testing
- Generic Api
- Multipart