balanced / httpproxy

A transparent HTTP proxy library
Other
5 stars 7 forks source link

Provide a base proxy object #1

Open mjallday opened 9 years ago

mjallday commented 9 years ago

I have to read the docs to understand which properties and methods I need to provide.

Why not give me a

class Proxy(object):
    host = None
    scheme = None
    def ingress_handler(self, uri, method, headers, data, charset):
        return dict(
             uri=uri,
             method=method,
             headers=headers,
             data=data,
             charset=charset,
        )

    def egress_handler(self, uri, method, status, headers, data):
        return dict(
            status=status,
            headers=headers,
            data=data,
        )

That way if I inherit from this class I get the benefit of syntax checking in my IDE.

fangpenlin commented 9 years ago

hmmm, make sense, will do

mahmoudimus commented 9 years ago

Umm actually why not just give me an callable for an ingress and egress?

mahmoudimus commented 9 years ago
proxy.register_ingress(lambda some_ingress: ... )
proxy.register_egress(....)

OR

@proxy.register_egress
def some_egress():
      pass
fangpenlin commented 9 years ago

@mahmoudimus I don't think it's necessary, since all I have to do is to provide minimum and complete interface, and all these register_ingress stuff can be done in implementation of proxy.