Skip to content

Commit

Permalink
allow using insecure connections for asset integration
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsdas committed Jul 7, 2022
1 parent b295154 commit e6409bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion care/utils/assetintegration/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

import requests
from django.conf import settings
from rest_framework.exceptions import APIException


Expand All @@ -9,12 +10,16 @@ def __init__(self, meta):
self.meta = meta
self.host = self.meta["local_ip_address"]
self.middleware_hostname = self.meta["middleware_hostname"]
self.insecure_connection = self.meta.get("insecure_connection", False)

def handle_action(self, action):
pass

def get_url(self, endpoint):
return "https://{}/{}".format(self.middleware_hostname, endpoint)
protocol = "http"
if not self.insecure_connection or settings.IS_PRODUCTION:
protocol += "s"
return f"{protocol}://{self.middleware_hostname}/{endpoint}"

def api_post(self, url, data=None):
req = requests.post(url, json=data)
Expand Down

0 comments on commit e6409bd

Please sign in to comment.