This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.client import AnyServiceInvoker | |
class ZatoMiddleware(object): | |
def process_request(self, req): | |
req.zato_client = AnyServiceInvoker('http://localhost:17010', | |
'/django/sample', ('django-app', 'django-password')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="." method="get"> | |
From EUR to | |
<input type="text" name="to" value="{{ to }}" /> | |
<input type="submit" value="Get exchange rates" /> | |
</form> | |
<table id="rates"> | |
<tr> | |
<th>Provider</th> | |
<th>Rate</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
# stdlib | |
from datetime import datetime | |
from traceback import format_exc | |
# anyjson | |
from anyjson import loads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ zato service invoke /opt/server1/ zato.security.basic-auth.get-list \ | |
--payload '{"cluster_id":1}' | |
[{u'username': u'admin.invoke', u'is_active': True, | |
u'realm': u'Zato admin invoke', u'id': 1L, u'name': u'admin.invoke'}, | |
{u'username': u'pubapi', u'is_active': True, u'realm': u'Zato public API', | |
u'id': 2L, u'name': u'pubapi'}] | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ zato service invoke /opt/server1 zato.security.basic-auth.get-list \ | |
--data-format xml \ | |
--payload '<zato_security_basic_auth_get_list_request><cluster_id>1</cluster_id>\ | |
</zato_security_basic_auth_get_list_request>' | |
<zato_security_basic_auth_get_list_response xmlns="https://zato.io/ns/20130518"> | |
<zato_env> | |
<cid>K034857440351657368008263132215876374901</cid> | |
<result>ZATO_OK</result> | |
</zato_env> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# At most 10 concurrent connections from a client | |
acl too_fast fe_sess_rate ge 10 | |
# Matches any path beginning with a given prefix | |
acl bursts_inclined path_beg -i /client1 | |
# Effectively working as a delay mechanism for clients that are too fast | |
tcp-request inspect-delay 1000ms | |
# Fast-path - accept connection if it's not this troublesome client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frontend front_http_plain | |
mode http | |
default_backend bck_http_plain | |
acl too_fast fe_sess_rate ge 10 | |
acl bursts_inclined path_beg -i /client1 | |
tcp-request inspect-delay 1000ms | |
tcp-request content accept unless bursts_inclined too_fast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.server.service import Service | |
class MyService(Service): | |
def handle(self): | |
# JMS WebSphere MQ | |
self.outgoing.jms_wmq.conn.send(self.request.payload, 'JMS MQ app', 'QUEUE.1') | |
# AMQP | |
self.outgoing.amqp.conn.send(self.request.payload, 'AMQP app', 'EXCH.1', '/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# anyjson | |
from anyjson import loads | |
# bunch | |
from bunch import bunchify | |
# decimal | |
from decimal import Decimal | |
# lxml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.server.service import Service | |
class MyService(Service): | |
def handle(self): | |
# message to decrypt defaults to self.request.raw_request | |
decrypted = self.xmlsec.decrypt('key-alias') | |
# no default message to decrypt | |
encrypted = self.xmlsec.encrypt('key-alias', 'message') |