Coder Social home page Coder Social logo

Comments (4)

carson-katri avatar carson-katri commented on September 1, 2024 1

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.

o-nnerb avatar o-nnerb commented on September 1, 2024

You can work with opaque type but I don't know very much about that technique

from swift-request.

o-nnerb avatar o-nnerb commented on September 1, 2024

Awesome suggestion! This will make request so much cleaner 👏🏻

from swift-request.

o-nnerb avatar o-nnerb commented on September 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.