mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Add examples
This commit is contained in:
20
examples/proxy/python/proxy.py
Normal file
20
examples/proxy/python/proxy.py
Normal file
@ -0,0 +1,20 @@
|
||||
import uuid
|
||||
import requests
|
||||
import json
|
||||
|
||||
registry_uri = "http://localhost:8081/registry"
|
||||
call_uri = "http://localhost:8081"
|
||||
headers = {'content-type': 'application/json'}
|
||||
|
||||
def register(service):
|
||||
return requests.post(registry_uri, data=json.dumps(service), headers=headers)
|
||||
|
||||
def deregister(service):
|
||||
return requests.delete(registry_uri, data=json.dumps(service), headers=headers)
|
||||
|
||||
def rpc_call(path, request):
|
||||
return requests.post(call_uri + path, data=json.dumps(request), headers=headers).json()
|
||||
|
||||
def http_call(path, request):
|
||||
return requests.post(call_uri + path, data=request)
|
||||
|
Reference in New Issue
Block a user