Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Is it possible to define variales for different environments #271

Open
ryang-bgl opened this issue Nov 16, 2021 · 1 comment
Open

Is it possible to define variales for different environments #271

ryang-bgl opened this issue Nov 16, 2021 · 1 comment

Comments

@ryang-bgl
Copy link

Hi,

Thanks a lot for authoring this awesome package.

Wonder if there is a way to switch between different environments for the vars in the restclient file. eg. I might use the same set of request (urls) for local and test environments. some vars like hostname will be different for different environments. Would be nice to easily switch environments.
One solution would be to put environment related vars in a separate file and included them at the beginning of the restclient file.

What do you think?

Thanks

@ryang-bgl
Copy link
Author

I managed to achieve what I need using the following approach, document it here in case someone might find it useful.

  1. put variables in a separate file, like in local.el
    (setq api-host "http://localhost:9000"
    user-name "test-user")
  2. load the file at the begining of the restclient file:

(load (concat (file-name-directory buffer-file-name) "local.el"))

  1. evaluate the load statement
  2. then reference those variables in restclient file:
    :api-host := (concat api-host "/get-users")
    :custom-headers := <<
    (concat "username: " user-name "\n"
    "userId: " 1 "\n")

You can have another file called production.el and just put the same set of variables.
when you want to switch envs, just evaluate the loading statement of that env.

@pashky if you think the above is ok, could you help to put those into documentation?

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant