A simple wrapper/plugin for requests for RFC-2782 style services, i.e. for FQDNs starting with an underscore it will access a resource pointed by an SRV record instead of the A record. Useful for seamless service discovery with DNS-based service discovery service like Consul.
import requests_srv as requests
print requests.get('http://_consul._http.service.consul/v1/catalog/services').text
from requests import Session
from requests_srv import SRVResolverHTTPAdapter
session = Session()
session.mount('http://_', SRVResolverHTTPAdapter())
session.mount('https://_', SRVResolverHTTPAdapter())
Test environent is set up in docker containers. To set up and run:
bash test.sh
Just as requests, request_srv is licensed under the Apache License, version 2.0
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.