Skip to content

Commit

Permalink
do not encode the ack with json without an option for it
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Oct 19, 2024
1 parent c5acb90 commit 0ac000a
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 133 deletions.
9 changes: 4 additions & 5 deletions src/exabgp/reactor/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@ def log_failure(self, message, level='ERR'):
log.error(report, 'processes', level)

def process(self, reactor, service, command):
use_json = False
# it to allow a global "set encoding json"
# it to allow a global "set encoding text"
# to not have to set the encoding on each command
if 'json' in command.split(' '):
return self.response(reactor, service, command, True)
if 'text' in command.split(' '):
return self.response(reactor, service, command, False)
return self.response(reactor, service, command, False)
use_json = True
return self.response(reactor, service, command, use_json)

def response(self, reactor, service, command, use_json):
api = 'json' if use_json else 'text'
for registered in self.functions:
if registered == command or command.endswith(' ' + registered) or registered + ' ' in command:
return self.callback[api][registered](self, reactor, service, command, use_json)
reactor.processes.answer_error(service, use_json)
reactor.processes.answer_error(service)
log.warning('command from process not understood : %s' % command, 'api')
return False

Expand Down
Loading

0 comments on commit 0ac000a

Please sign in to comment.