from ._config import get_config
from .models import Request, Response
from .status_codes import codes
-from .hooks import dispatch_hooks
+from .hooks import dispatch_hook
from .utils import cookiejar_from_dict, header_expand
)
# Arguments manipulation hook.
- args = dispatch_hooks('args', hooks, args)
+ args = dispatch_hook('args', hooks, args)
# Create Request object.
r = Request(**args)
# Pre-request hook.
- r = dispatch_hooks('pre_request', hooks, r)
+ r = dispatch_hook('pre_request', hooks, r)
# Only construct the request (for async)
if _return_request:
# TODO: Add these hooks inline.
# Post-request hook.
- r = dispatch_hooks('post_request', hooks, r)
+ r = dispatch_hook('post_request', hooks, r)
# Response manipulation hook.
- r.response = dispatch_hooks('response', hooks, r.response)
+ r.response = dispatch_hook('response', hooks, r.response)
return r.response
import collections
-def dispatch_hooks(key, hooks, hook_data):
+def dispatch_hook(key, hooks, hook_data):
"""Dipatches a hook dictionary on a given peice of data."""
hooks = (hooks or {}).get(key, [])