ENV Url

License Cargo Documentation

Env-composable service urls complete with key overrides as to facilitate maximum flexibility and to simplify integration with kubernetes.

## Env mapping behaviors

| ENV | | | -----------------------:|:---------------------------------------------------------:| | {PREFIX}URL | set service url, disregarding other overrides | | {PREFIX}URLENV | override {PREFIX}_URL env mapping | | {PREFIX}SCHEME | set url scheme component | | {PREFIX}SCHEMEENV | override {PREFIX}_SCHEME env mapping | | {PREFIX}HOST | set url host component | | {PREFIX}HOSTENV | override {PREFIX}_HOST env mapping | | {PREFIX}PATH | set url path component | | {PREFIX}PATHENV | override {PREFIX}_PATH env mapping | | {PREFIX}QUERY | set url query component | | {PREFIX}QUERYENV | override {PREFIX}_QUERY env mapping | | {PREFIX}USERINFO | set url userinfo component | | {PREFIX}USERINFOENV | override {PREFIX}_USERINFO env mapping |

## Example

``` use env_url::*;

#[derive(EnvURL)] #[envurl(envprefix = "REDIS", default = "redis://127.0.0.1:6379")] pub struct RedisDB;

let serviceurl = RedisDB::serviceurl();

```

Kubernetes usage

As kubernetes can set services to env variables for service discovery, it's very useful to be able to override the env mappings like so

REDIS_HOST_ENV: STAGE_REDIS_MASTER_PORT_6379_TCP_ADDR REDIS_PORT_ENV: STAGE_REDIS_MASTER_SERVICE_PORT_REDIS