MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / wrapper

Method wrapper

21-async/mojifinder/bottle.py:1746–1761  ·  view source on GitHub ↗
(*a, **ka)

Source from the content-addressed store, hash-verified

1744 dumps = self.json_dumps
1745 if not dumps: return callback
1746 def wrapper(*a, **ka):
1747 try:
1748 rv = callback(*a, **ka)
1749 except HTTPError:
1750 rv = _e()
1751
1752 if isinstance(rv, dict):
1753 #Attempt to serialize, raises exception on failure
1754 json_response = dumps(rv)
1755 #Set content type only if serialization succesful
1756 response.content_type = 'application/json'
1757 return json_response
1758 elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict):
1759 rv.body = dumps(rv.body)
1760 rv.content_type = 'application/json'
1761 return rv
1762
1763 return wrapper
1764

Callers

nothing calls this directly

Calls 1

_eFunction · 0.85

Tested by

no test coverage detected