{"id":1613,"url":"https://github.com/BridgeNetworking/Bridge","last_synced_at":"2025-08-02T04:32:25.850Z","repository":{"id":35695754,"uuid":"39972819","full_name":"BridgeNetworking/Bridge","owner":"BridgeNetworking","description":"Extensible HTTP Networking for iOS","archived":false,"fork":false,"pushed_at":"2022-05-03T04:59:56.000Z","size":18590,"stargazers_count":89,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"dev","last_synced_at":"2025-07-12T12:48:45.036Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BridgeNetworking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T21:14:24.000Z","updated_at":"2024-03-10T10:05:31.000Z","dependencies_parsed_at":"2022-08-21T02:50:13.473Z","dependency_job_id":null,"html_url":"https://github.com/BridgeNetworking/Bridge","commit_stats":null,"previous_names":["rawrjustin/bridge"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/BridgeNetworking/Bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BridgeNetworking%2FBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BridgeNetworking%2FBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BridgeNetworking%2FBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BridgeNetworking%2FBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BridgeNetworking","download_url":"https://codeload.github.com/BridgeNetworking/Bridge/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BridgeNetworking%2FBridge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334617,"owners_count":24233793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:51.397Z","updated_at":"2025-08-02T04:32:22.827Z","avatar_url":"https://github.com/BridgeNetworking.png","language":"Swift","funding_links":[],"categories":["Networking"],"sub_categories":["Video","Other free courses"],"readme":"# Bridge [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Bridge.svg)](https://img.shields.io/cocoapods/v/Bridge.svg)\n\nSimple Typed JSON HTTP Networking in Swift 4.0\n\n#### GET\n```swift\nGET\u003cDict\u003e(\"http://httpbin.org/ip\").execute(success: { (response) in\n    let ip: Dict = response\n})\n\nlet postID = \"1\"\nGET\u003cDict\u003e(\"http://jsonplaceholder.typicode.com/posts/#\").execute(postID, success: { (response) in\n    let post: Dict = response\n})\n```\n\n#### POST\n```swift\nlet userComment = [\"justin\": \"wow this is cool\"]\nlet endpoint = POST\u003c[String: AnyObject]\u003e(\"https://api.bridge.com/comments\")\nendpoint.execute(params: userComment, success: { (commentResponse: [String: AnyObject]) -\u003e () in\n    // Handle success\n}, failure: { (error, data, request, response) in\n    // Handle failure\n})\n```\n\n\n## Interceptors\n\nThe power of Bridge is that it lets you create custom \"Interceptors\" to intercept process your requests before they are sent off to the internets, or to intercept and process your responses before they are returned to the caller's success block.\n\nAttach custom headers based on the endpoint, write retry handling, write authentication handlers, use method tunneling. Interceptors allow Bridge to be extremely extensible to your project needs.\n\n```swift\n/**\n*  Conform to the `ResponseInterceptor` protocol for any Bridge that\n*  needs to work with or alter a request before it's sent over the wire\n*/\npublic protocol ResponseInterceptor {\n    func process\u003cReturnType\u003e(endpoint: Endpoint\u003cReturnType\u003e, inout mutableRequest: NSMutableURLRequest)\n}\n\n/**\n*  Conform to the `ResponseInterceptor` protocol to work with data after\n*  the request is returned with a response.\n*/\npublic protocol ResponseInterceptor {\n    func process\u003cReturnType\u003e(endpoint: Endpoint\u003cReturnType\u003e, response: NSHTTPURLResponse?, responseObject: ResponseObject) -\u003e ProcessResults\n}\n\n```\nExamples:\n- [Retry](https://gist.github.com/rawrjustin/1e35c5998a53a987b23d) (Retries requests on response if not 2xx code)\n- [Model Cache](https://gist.github.com/rawrjustin/7331da16d6e637db20dc) (Caches objects on response)\n- [Method Tunneling]() (Changes the HTTP Verb)\n\n\n## Object Serialization\nBridge is implemented using generics which allow you to serialize to objects as long as your objects conform to the `Parseable` protocol.\n\n```swift\npublic protocol Parseable {\n    static func parseResponseObject(responseObject: AnyObject) throws -\u003e AnyObject\n}\n```\n\nIt is left completely up to the developer on how you want to implement the `Parseable` protocol. You can manually create and serialize your objects:\n\n```swift\nclass User: AnyObject, Parseable {\n    var name: String?\n    var email: String?\n    var pictureURL: NSURL?\n\n    static func parseResponseObject(responseObject: AnyObject) throws -\u003e AnyObject {\n        if let dict = responseObject as? Dictionary\u003cString, AnyObject\u003e {\n            let user = User()\n            user.name = dict[\"name\"] as? String\n            user.email = dict[\"email\"] as? String\n            user.pictureURL = NSURL(string: dict[\"avatar_url\"] as! String)\n            return user\n        }\n        // If parsing encounters an error, throw enum that conforms to ErrorType.\n        throw BridgeErrorType.Parsing\n    }\n}\n```\n\nOr you can also serialize them using whatever serialization libraries you like. [This gist](https://gist.github.com/rawrjustin/79f5186717fbc38c0b617a390ab9c0f0) is an example of out out-of-box working solution for [Mantle](https://github.com/Mantle/Mantle) if you're already using Mantle models. *No code change* is required to your Mantle models.\n\nOnce models are setup, making calls are as simple as:\n```swift\nlet endpoint = GET\u003cGithubUser\u003e(\"https://api.github.com/users/rawrjustin\")\nendpoint.execute(success: { (user: GithubUser) in\n    print(user)\n})\n\nlet endpoint = GET\u003cArray\u003cGithubUser\u003e\u003e(\"https://api.github.com/users\")\nendpoint.execute(success: { (users: Array\u003cGithubUser\u003e) in\n    print(users)\n}, failure: { (error: NSError?) in\n    print(error)\n})\n```\n\n## Advanced Features\n\n#### Base URL\nYou can set the base url of your Bridge client\n```swift\nBridge.sharedInstance.baseURL = \"http://api.github.com\"\nGET\u003cGithubUser\u003e(\"/users/rawrjustin\") // expands to http://api.github.com/users/rawrjustin\n```\n\n#### Cancellation by Tag\nEasily cancel any requests tagged with an identifier.\n```swift\nBridge.sharedInstance.cancelWithTag(\"DebouncedSearch\")\n```\n\n#### Variable endpoints\nSimilar to how Rails maps :id for resources, `#` is used as the character where a variable would be inserted into the path.\n\n`GET\u003cDict\u003e(\"/photos/#\")` will map to `/photos/1` if you pass in `1` in the first variadic parameter when you call execute(). You can have multiple variables, they will be mapped in order respectively.\n\n#### Additional HTTP headers\n\n#### Endpoint Specific Interceptors\n\n## Requirements\n - iOS 8.0+\n - Swift 4.0\n\n## Installation\n\n[Cocoapods](http://cocoapods.org/)\n\n```\npod 'Bridge', '0.4.3'\n```\n\n[Carthage](https://github.com/Carthage/Carthage)\n\n```\ngithub \"rawrjustin/Bridge\"\n```\n\n## License\nBridge is [licensed](https://github.com/rawrjustin/Bridge/blob/master/LICENSE.md) under MIT license.  \n\n## Questions?\n\nOpen an [issue](https://github.com/rawrjustin/Bridge/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBridgeNetworking%2FBridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBridgeNetworking%2FBridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBridgeNetworking%2FBridge/lists"}