You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
@@ -1,4 +1,12 @@
|
||||
from httpie.plugins.base import AuthPlugin, FormatterPlugin, ConverterPlugin
|
||||
"""
|
||||
WARNING: The plugin API is still work in progress and will
|
||||
probably be completely reworked by v1.0.0.
|
||||
|
||||
"""
|
||||
from httpie.plugins.base import (
|
||||
AuthPlugin, FormatterPlugin,
|
||||
ConverterPlugin, TransportPlugin
|
||||
)
|
||||
from httpie.plugins.manager import PluginManager
|
||||
from httpie.plugins.builtin import BasicAuthPlugin, DigestAuthPlugin
|
||||
from httpie.output.formatters.headers import HeadersFormatter
|
||||
|
@@ -15,7 +15,7 @@ class AuthPlugin(BasePlugin):
|
||||
"""
|
||||
Base auth plugin class.
|
||||
|
||||
See <https://github.com/jkbr/httpie-ntlm> for an example auth plugin.
|
||||
See <https://github.com/jakubroztocil/httpie-ntlm> for an example auth plugin.
|
||||
|
||||
"""
|
||||
# The value that should be passed to --auth-type
|
||||
@@ -30,6 +30,25 @@ class AuthPlugin(BasePlugin):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class TransportPlugin(BasePlugin):
|
||||
"""
|
||||
|
||||
http://docs.python-requests.org/en/latest/user/advanced/#transport-adapters
|
||||
|
||||
"""
|
||||
|
||||
# The URL prefix the adapter should be mount to.
|
||||
prefix = None
|
||||
|
||||
def get_adapter(self):
|
||||
"""
|
||||
Return a ``requests.adapters.BaseAdapter`` subclass instance to be
|
||||
mounted to ``self.prefix``.
|
||||
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class ConverterPlugin(object):
|
||||
|
||||
def __init__(self, mime):
|
||||
|
@@ -1,12 +1,14 @@
|
||||
from itertools import groupby
|
||||
from pkg_resources import iter_entry_points
|
||||
from httpie.plugins import AuthPlugin, FormatterPlugin, ConverterPlugin
|
||||
from httpie.plugins.base import TransportPlugin
|
||||
|
||||
|
||||
ENTRY_POINT_NAMES = [
|
||||
'httpie.plugins.auth.v1',
|
||||
'httpie.plugins.formatter.v1',
|
||||
'httpie.plugins.converter.v1',
|
||||
'httpie.plugins.transport.v1',
|
||||
]
|
||||
|
||||
|
||||
@@ -56,3 +58,8 @@ class PluginManager(object):
|
||||
def get_converters(self):
|
||||
return [plugin for plugin in self
|
||||
if issubclass(plugin, ConverterPlugin)]
|
||||
|
||||
# Adapters
|
||||
def get_adapter_plugins(self):
|
||||
return [plugin for plugin in self
|
||||
if issubclass(plugin, TransportPlugin)]
|
||||
|
Reference in New Issue
Block a user