potamides / pantran.nvim

Use your favorite machine translation engines without having to leave your favorite editor.
MIT License
289 stars 2 forks source link

feat(curl): add proxy functionality (#15) #16

Closed Mythos-404 closed 1 year ago

Mythos-404 commented 1 year ago

A proxy that uses the HTTP protocol

potamides commented 1 year ago

A potential shortcoming of your approach is that it does not address all proxy functionality provided by curl (e.g. username or password of the proxy). To also account for future use cases, an alternative would be to simply add a default_args table instead, allowing the user to add arbitrary flags to the curl command.

Mythos-404 commented 1 year ago

Thanks for the review. This default_args how do I achieve it

potamides commented 1 year ago

This default_args how do I achieve it

Somethink like this:

  local args = vim.tbl_extend("error", self.config.user_args, {
    "--fail-with-body",
    "--retry", self.config.retry,
    "--max-time", self.config.timeout,
    "--retry-max-time", self.config.timeout,
    "--request", request,
    "--header", "accept: application/json",
    tostring(self._url / path)
  })

Then users can add user_args = {"-x", "https://whatever.com:1234"} to their config and be done with it. I think that would be the way to go.