-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpTrigger.fs
30 lines (24 loc) · 961 Bytes
/
HttpTrigger.fs
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
namespace FunctionApp
module FunctionModule =
open Microsoft.AspNetCore.Mvc
open Microsoft.Azure.WebJobs
open Microsoft.AspNetCore.Http
open System.IO
open Microsoft.Extensions.Logging
open TLEReader
[<FunctionName("ReadTle")>]
let Run ([<HttpTrigger(Methods=[|"POST"|])>] req:HttpRequest) (log:ILogger) =
async {
"Runnning Function"
|> log.LogInformation
let! body =
new StreamReader(req.Body)
|> (fun stream -> stream.ReadToEndAsync())
|> Async.AwaitTask
let result =
match body with
| null -> BadRequestResult() :> ActionResult
| "" -> BadRequestResult() :> ActionResult
| _ -> JsonResult(TwoLineElementReader.parseSatelliteInformations body) :> ActionResult
return result
} |> Async.StartAsTask