• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 16728975479

04 Aug 2025 04:41PM UTC coverage: 76.88% (-0.6%) from 77.485%
16728975479

Pull #766

github

web-flow
Merge a57ff40e5 into e072a5824
Pull Request #766: chore: HTTP layer from OpenAPIRuntime

76 of 134 new or added lines in 4 files covered. (56.72%)

54 existing lines in 2 files now uncovered.

5520 of 7180 relevant lines covered (76.88%)

23.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Sources/Helpers/HTTP/Client.swift
1
import HTTPTypes
2
import OpenAPIRuntime
3

4
#if canImport(Darwin)
5
  import struct Foundation.URL
6
#else
7
  @preconcurrency import struct Foundation.URL
8
#endif
9

10
/// A client that can send HTTP requests and receive HTTP responses.
11
struct Client: Sendable {
12

13
  /// The URL of the server, used as the base URL for requests made by the
14
  /// client.
15
  let serverURL: URL
16

17
  /// A type capable of sending HTTP requests and receiving HTTP responses.
18
  var transport: any ClientTransport
19

20
  /// The middlewares to be invoked before the transport.
21
  var middlewares: [any ClientMiddleware]
22

23
  /// Creates a new client.
24
  init(
25
    serverURL: URL,
26
    transport: any ClientTransport,
27
    middlewares: [any ClientMiddleware] = []
NEW
28
  ) {
×
NEW
29
    self.serverURL = serverURL
×
NEW
30
    self.transport = transport
×
NEW
31
    self.middlewares = middlewares
×
NEW
32
  }
×
33

34
  /// Sends the HTTP request and returns the HTTP response.
35
  ///
36
  /// - Parameters:
37
  ///   - request: The HTTP request to send.
38
  ///   - body: The HTTP request body to send.
39
  /// - Returns: The HTTP response and its body.
40
  /// - Throws: An error if any part of the HTTP operation process fails.
41
  func send(
42
    _ request: HTTPTypes.HTTPRequest,
43
    body: HTTPBody? = nil
NEW
44
  ) async throws -> (HTTPTypes.HTTPResponse, HTTPBody?) {
×
NEW
45
    let baseURL = serverURL
×
NEW
46
    var next:
×
NEW
47
      @Sendable (HTTPTypes.HTTPRequest, HTTPBody?, URL) async throws -> (
×
NEW
48
        HTTPTypes.HTTPResponse, HTTPBody?
×
NEW
49
      ) = {
×
NEW
50
        (_request, _body, _url) in
×
NEW
51
        try await transport.send(
×
NEW
52
          _request,
×
NEW
53
          body: _body,
×
NEW
54
          baseURL: _url,
×
NEW
55
          operationID: ""
×
NEW
56
        )
×
NEW
57
      }
×
NEW
58
    for middleware in middlewares.reversed() {
×
NEW
59
      let tmp = next
×
NEW
60
      next = { (_request, _body, _url) in
×
NEW
61
        try await middleware.intercept(
×
NEW
62
          _request,
×
NEW
63
          body: _body,
×
NEW
64
          baseURL: _url,
×
NEW
65
          operationID: "",
×
NEW
66
          next: tmp
×
NEW
67
        )
×
NEW
68
      }
×
NEW
69
    }
×
NEW
70
    return try await next(request, body, baseURL)
×
NEW
71
  }
×
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc