swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.13k stars 102 forks source link

Question/Request: Make HTTP requests #149

Closed cardoso closed 4 years ago

cardoso commented 4 years ago

Can you make HTTP requests with this? Eg. to respond to a webhook, integrate APIs

I see there's the HTTPClient, which looks like it does HTTP requests, but it's currently internal.

ktoso commented 4 years ago

You can use the https://github.com/swift-server/async-http-client library

We're also working towards instrumenting it for tracing (with the swift-tracing instrumentation efforts), so it'd automatically carry XRay tracing headers as well 👍

cardoso commented 4 years ago

Thanks a lot @ktoso :)

fabianfett commented 4 years ago

@cardoso if you are more familiar with URLSession you can also just use it. Just make sure to import FoundationNetworking on Linux to get access to URLSession.

cardoso commented 4 years ago

That's even better. Thank you @fabianfett

fabianfett commented 4 years ago

@cardoso an example for you: https://github.com/swift-server/swift-aws-lambda-runtime/blob/master/Examples/LambdaFunctions/Sources/CurrencyExchange/main.swift