{"id":17978755,"url":"https://github.com/jessyancoding/retrofiturlmanager","last_synced_at":"2025-05-15T18:09:50.355Z","repository":{"id":47165587,"uuid":"97385710","full_name":"JessYanCoding/RetrofitUrlManager","owner":"JessYanCoding","description":"🔮 Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).","archived":false,"fork":false,"pushed_at":"2020-04-18T03:44:26.000Z","size":16160,"stargazers_count":2195,"open_issues_count":12,"forks_count":309,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-03-31T22:20:06.561Z","etag":null,"topics":["arms","baseurl","baseurl-domain","mvparms","okhttp","okhttp3","retrofit","retrofit2"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JessYanCoding.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-16T13:37:29.000Z","updated_at":"2025-03-31T13:52:40.000Z","dependencies_parsed_at":"2022-08-05T07:30:19.445Z","dependency_job_id":null,"html_url":"https://github.com/JessYanCoding/RetrofitUrlManager","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JessYanCoding%2FRetrofitUrlManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JessYanCoding%2FRetrofitUrlManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JessYanCoding%2FRetrofitUrlManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JessYanCoding%2FRetrofitUrlManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JessYanCoding","download_url":"https://codeload.github.com/JessYanCoding/RetrofitUrlManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744334,"owners_count":20988783,"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","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":["arms","baseurl","baseurl-domain","mvparms","okhttp","okhttp3","retrofit","retrofit2"],"created_at":"2024-10-29T17:35:01.305Z","updated_at":"2025-04-07T23:08:59.756Z","avatar_url":"https://github.com/JessYanCoding.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RetrofitUrlManager\n[ ![Jcenter](https://img.shields.io/badge/Jcenter-v1.4.0-brightgreen.svg?style=flat-square) ](https://bintray.com/jessyancoding/maven/retrofit-url-manager/1.4.0/link)\n[ ![Build Status](https://travis-ci.org/JessYanCoding/RetrofitUrlManager.svg?branch=master) ](https://travis-ci.org/JessYanCoding/RetrofitUrlManager)\n[ ![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RetrofitUrlManager-brightgreen.svg?style=flat-square) ](https://android-arsenal.com/details/1/6007)\n[ ![API](https://img.shields.io/badge/API-9%2B-blue.svg?style=flat-square) ](https://developer.android.com/about/versions/android-2.3.html)\n[ ![License](http://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square) ](http://www.apache.org/licenses/LICENSE-2.0)\n[ ![Author](https://img.shields.io/badge/Author-JessYan-orange.svg?style=flat-square) ](https://www.jianshu.com/u/1d0c0bc634db)\n[ ![QQ-Group](https://img.shields.io/badge/QQ%E7%BE%A4-455850365%20%7C%20301733278-orange.svg?style=flat-square) ](https://shang.qq.com/wpa/qunwpa?idkey=7e59e59145e6c7c68932ace10f52790636451f01d1ecadb6a652b1df234df753)\n\n## Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime.\n\n## Overview\n![overview](art/overview.gif)\n\n## Introduction\n以最简洁的 **Api** 让 **Retrofit** 同时支持多个 **BaseUrl** 以及动态改变 **BaseUrl**.\n\n## Notice\n[**框架的分析和思路 (一)**](http://www.jianshu.com/p/2919bdb8d09a)\n\n[**框架的分析和思路 (二)**](https://www.jianshu.com/p/35a8959c2f86)\n\n[**更完整的 Sample**](https://github.com/JessYanCoding/ArmsComponent)\n\n## Download\n``` gradle\n implementation 'me.jessyan:retrofit-url-manager:1.4.0'\n```\n\n## Usage\n### Initialize\n``` java\n // 构建 OkHttpClient 时,将 OkHttpClient.Builder() 传入 with() 方法,进行初始化配置\n OkHttpClient = RetrofitUrlManager.getInstance().with(new OkHttpClient.Builder())\n                .build();\n```\n\n### Step 1\n``` java\n public interface ApiService {\n     @Headers({\"Domain-Name: douban\"}) // 加上 Domain-Name header\n     @GET(\"/v2/book/{id}\")\n     Observable\u003cResponseBody\u003e getBook(@Path(\"id\") int id);\n}\n\n```\n\n### Step 2\n``` java\n // 可在 App 运行时,随时切换 BaseUrl (指定了 Domain-Name header 的接口)\n RetrofitUrlManager.getInstance().putDomain(\"douban\", \"https://api.douban.com\");\n```\n\n### If you want to change the global BaseUrl\n```java\n // 全局 BaseUrl 的优先级低于 Domain-Name header 中单独配置的,其他未配置的接口将受全局 BaseUrl 的影响\n RetrofitUrlManager.getInstance().setGlobalDomain(\"your BaseUrl\");\n\n```\n\n## About Me\n* **Email**: \u003cjess.yan.effort@gmail.com\u003e\n* **Home**: \u003chttp://jessyan.me\u003e\n* **掘金**: \u003chttps://juejin.im/user/57a9dbd9165abd0061714613\u003e\n* **简书**: \u003chttps://www.jianshu.com/u/1d0c0bc634db\u003e\n\n## License\n```\n Copyright 2017, jessyan\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessyancoding%2Fretrofiturlmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjessyancoding%2Fretrofiturlmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessyancoding%2Fretrofiturlmanager/lists"}