summaryrefslogtreecommitdiff
path: root/yarns/lib.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-12-15 16:45:33 +0200
committerLars Wirzenius <liw@liw.fi>2017-12-15 16:45:33 +0200
commitd8f880bec11ee7d81a3715a1677b4b29ebbef201 (patch)
treeaa3bb8c8e5de96953d2025d3316c2ee04087082c /yarns/lib.py
parentb5b953029a26e1e8701d75149581497bdcf26a96 (diff)
downloadick2-d8f880bec11ee7d81a3715a1677b4b29ebbef201.tar.gz
Refactor: add function http, for easier requests
Diffstat (limited to 'yarns/lib.py')
-rw-r--r--yarns/lib.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/yarns/lib.py b/yarns/lib.py
index 6575e6d..8f885c0 100644
--- a/yarns/lib.py
+++ b/yarns/lib.py
@@ -96,6 +96,14 @@ def get_token(user):
return cat(filename)
+def http(vars, func, url, **kwargs):
+ status, content_type, headers, body = func(url, **kwargs)
+ vars['status_code'] = status
+ vars['content_type'] = content_type
+ vars['headers'] = headers
+ vars['body'] = body
+
+
def get(url, token):
headers = {
'Authorization': 'Bearer {}'.format(token),