Comments (4)
Great suggestion. I think we'll have to avoid Self
in the protocol so we can form an Array
of the items. It would probably work well without being a static func
:
protocol RequestParam {
/// Here the param can modify the `URLRequest` in any way necessary.
func buildParam(_ request: inout URLRequest)
}
struct Body: RequestParam {
...
public func buildParam(_ request: inout URLRequest) {
request.httpBody = data
}
}
We may also want to pass the URLSession
in case they need to modify that. This also opens the possibility for user-created params :)
from swift-request.
You can work with opaque type but I don't know very much about that technique
from swift-request.
Awesome suggestion! This will make request so much cleaner 👏🏻
from swift-request.
I will keep this topic open so we can track PR and discuss at any time.
About URLSession, I guess that this could be pass to RequestParam or maybe to other protocol that extends RequestParam, so Request struct can call the function, for example, trackSession(_ session: URLSession)
, after request starts.
from swift-request.
Related Issues (20)
- Merge two Url with + operator HOT 1
- Add buildEither on RequestBuilder
- Support MultipartFormData
- Add MIT license on swift files
- Question: RequestView JSON API HOT 1
- RequestView refresh? HOT 15
- RequestImage remove animation HOT 6
- Question: Pagination HOT 8
- Add possibility to send value through form data
- Form.Data is not sending the name of the file when it doesn't has a type of file
- RequestChain nil data HOT 3
- Question: RequestImage support for SVG images? HOT 2
- updatePublisher internal protection HOT 2
- 400 HOT 2
- HTTP 403 when trying to post dictionary body HOT 2
- `async`/`await` support
- Issue with subscript not existing causing crash HOT 4
- This is a feature request for several improvements
- Question: Is there support for progress for transfers?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-request.