Skip to content

[Plugin] How to parameterize? #519

Locked Answered by abhinavsingh
deeplook asked this question in Q&A
Discussion options

You must be logged in to vote
    def handle_client_request(self, request: HttpParser) -> Optional[HttpParser]:
        # I'd prefer to pass this token to the constructor:
        request.add_header(b'Authorization', bytes(f"Bearer {token}", "utf-8"))
        return request

If the token here is static i.e. same for all outgoing requests, then flags will simply do the trick. You can define a flag like:

flags.add_argument(
    '--bearer-token',
    type=str,
    default=None,
    help='Default: None.  Bearer token.'
)

Then you can use this flag within the plugin as:

self.flags.bearer_token

If the token itself is dynamic, then it will be best to dynamically fetch the token from within the plugin when necessary.

I hope…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by abhinavsingh

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Question Questions related to proxy server
2 participants