13.07.2018, 08:56
pawn-env
Provides access to environment variables in Pawn.
Rule III of the Twelve Factor App states:
Store config in the environment
An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc). This includes:
(read the rest here)
Installation
Simply install to your project:
Include in your code and begin using the library:
Not a sampctl user? See the GitHub for source and binaries.
Usage
This package provides one function GetEnv which stores into dest the environment variable identified by name and returns the length of the result.
For example, this code loads a MySQL password from an environment variable:
Building
On Windows, to build the standard Windows .dll file: open CMakeLists.txt with Visual Studio 2017+ and develop/build using MSVC tools. To build the Linux build on Windows, run make build-linux and Docker will be used to compile it. On Linux, use CMake: mkdir build && cd build && cmake .. && make.
Testing
To test on Windows or Linux with the need for containers:
To the Linux build on Windows with a Docker container:
Provides access to environment variables in Pawn.
Rule III of the Twelve Factor App states:
Store config in the environment
An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc). This includes:
- Resource handles to the database, Memcached, and other backing services
- Credentials to external services such as Amazon S3 or *******
- Per-deploy values such as the canonical hostname for the deploy
(read the rest here)
Installation
Simply install to your project:
Код:
sampctl package install Southclaws/pawn-env
Код:
#include <env>
Usage
This package provides one function GetEnv which stores into dest the environment variable identified by name and returns the length of the result.
For example, this code loads a MySQL password from an environment variable:
Код:
main() { new mysqlPassword[128]; ret = GetEnv("MYSQL_PASSWORD", mysqlPassword); if(ret) { // use mysqlPassword to connect to DB } else { print("Environment variable `MYSQL_PASSWORD` not set."); } }
On Windows, to build the standard Windows .dll file: open CMakeLists.txt with Visual Studio 2017+ and develop/build using MSVC tools. To build the Linux build on Windows, run make build-linux and Docker will be used to compile it. On Linux, use CMake: mkdir build && cd build && cmake .. && make.
Testing
To test on Windows or Linux with the need for containers:
Код:
make test-windows
Код:
make test-linux