Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d9fd88

Browse files
committed
Merge branch 'mg-fully-qualified' into absolute-url
2 parents483d65d +ac3bc46 commit8d9fd88

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎python_anvil/api_resources/requests.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,32 @@ class PlainRequest(BaseAnvilHttpRequest):
161161

162162
defget_url(self):
163163
returnf"{self.API_HOST}/{self.API_BASE}"
164+
165+
166+
classFullyQualifiedRequest(BaseAnvilHttpRequest):
167+
"""A request class that validates URLs are fully qualified and point to Anvil domains."""
168+
169+
VALID_HOSTS= [
170+
"https://app.useanvil.com",
171+
# Future Anvil specific URLs
172+
]
173+
174+
def__init__(self,client,options=None):
175+
super().__init__(client,options)
176+
177+
defget_url(self):
178+
return""# Not used since we expect full URLs
179+
180+
def_validate_url(self,url):
181+
ifnotany(url.startswith(host)forhostinself.VALID_HOSTS):
182+
raiseValueError(
183+
f"URL must start with one of:{', '.join(self.VALID_HOSTS)}"
184+
)
185+
186+
defget(self,url,params=None,**kwargs):
187+
self._validate_url(url)
188+
returnsuper().get(url,params,**kwargs)
189+
190+
defpost(self,url,data=None,**kwargs):
191+
self._validate_url(url)
192+
returnsuper().post(url,data,**kwargs)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp