@@ -130,29 +130,28 @@ def __init__(self, verb: SupportedHTTPVerb, path: str, **params: Any) -> None:
130
130
131
131
class HTTPClient :
132
132
__slots__ = (
133
- "_async" ,
134
133
"_locks" ,
135
134
"_owns_session" ,
136
135
"_session" ,
137
136
"_token" ,
138
- "api_base " ,
137
+ "root_url " ,
139
138
"user_agent" ,
140
139
)
141
140
142
- def __init__ (self , * , session : aiohttp .ClientSession | None = None , api_base : str | None = None ) -> None :
141
+ def __init__ (self , * , session : aiohttp .ClientSession | None = None , root_url : str | None = None ) -> None :
143
142
self ._session : aiohttp .ClientSession | None = session
144
143
self ._owns_session : bool = False
145
144
self ._locks : weakref .WeakValueDictionary [str , asyncio .Lock ] = weakref .WeakValueDictionary ()
146
145
user_agent = "mystbin.py (https://github.com/PythonistaGuild/mystbin.py {0}) Python/{1[0]}.{1[1]} aiohttp/{2}"
147
146
self .user_agent : str = user_agent .format (__version__ , sys .version_info , aiohttp .__version__ )
148
- self ._resolve_api (api_base )
147
+ self ._resolve_api (root_url )
149
148
150
- def _resolve_api (self , api_base : str | None , / ) -> None :
151
- if api_base :
152
- Route .API_BASE = f"https:// { api_base } /api"
153
- self .api_base = Route . API_BASE
149
+ def _resolve_api (self , root_url : str | None , / ) -> None :
150
+ if root_url :
151
+ Route .API_BASE = root_url + "api" if root_url . endswith ( "/" ) else root_url + " /api"
152
+ self .root_url = root_url + ( "/" if not root_url . endswith ( "/" ) else "" )
154
153
else :
155
- self .api_base = "https://mystb.in/api "
154
+ self .root_url = "https://mystb.in/"
156
155
157
156
async def close (self ) -> None :
158
157
if self ._session and self ._owns_session :
0 commit comments