Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Make URL prefix configurable (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-davis committed Aug 30, 2019
1 parent 66521f6 commit c1c98cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ elastic:

```

To change the default url prefix (`/api`) add a new key-value at the top level:
```yaml
url_prefix: "/new_prefix"
```

To have *no* prefix, provide an empty string, i.e.
```yaml
url_prefix: ""`
```


### Dev Mode

Expand Down
2 changes: 1 addition & 1 deletion ebr_board/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_app( # pylint: disable=too-many-arguments
app = Flask(__name__) # pylint: disable=invalid-name
app.config.from_object(config)

api_bp = Blueprint("api", __name__, url_prefix="/api")
api_bp = Blueprint("api", __name__, url_prefix=config.get("url_prefix", "/api"))
configure_api(api_bp)

with app.app_context():
Expand Down
16 changes: 13 additions & 3 deletions ebr_board/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def __init__(self, config, vault_config, vault_creds, config_format=None, load_c
config_client = VaultAnyConfig(vault_config, ac_parser=config_format)
config_client.auto_auth(vault_creds, ac_parser=config_format)
if os.path.isfile(config):
config = config_client.load(config, process_secret_files=load_certs)
self.config = config_client.load(config, process_secret_files=load_certs)
else:
config = config_client.loads(config, process_secret_files=load_certs, ac_parser=config_format)
self.config = config_client.loads(config, process_secret_files=load_certs, ac_parser=config_format)

# Elastic Search
elastic_config = config["elastic"]
elastic_config = self.config["elastic"]
self.connect_elastic(elastic_config)
self.ES_INDEX = elastic_config["index"]

Expand All @@ -62,3 +62,13 @@ def connect_elastic(src_config):

local_src_config.update({"http_auth": user + ":" + password})
connections.create_connection(hosts=[local_src_config])

def get(self, key, default=None):
"""
Passes through to the config dictionary
Args:
key: key to retrieve from config
default: (optional) default value
"""

return self.config.get(key, default)

0 comments on commit c1c98cb

Please sign in to comment.