Skip to content

Commit

Permalink
Add routing env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Feb 24, 2023
1 parent 1234d0b commit 81763b1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
15 changes: 14 additions & 1 deletion infrastructure/kubernetes/modules/env/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,20 @@ module "k8s_tiler" {
{
name = "S3_BUCKET_URL"
value = var.science_bucket_name
}
},
{
name = "ROOT_PATH"
value = ""
},
{
name = "TITILER_PREFIX"
value = "/cog"
},
{
name = "TITILER_ROUTER_PREFIX"
value = "/cog"
},

]

}
Expand Down
3 changes: 3 additions & 0 deletions tiler/.env.default
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
REQUIRE_AUTH=
API_HOST=
S3_BUCKET_URL=
ROOT_PATH=
TITILER_PREFIX=
TITILER_ROUTER_PREFIX=
4 changes: 3 additions & 1 deletion tiler/app/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class Settings(BaseSettings):
api_port: str = getenv('API_PORT')
s3_bucket_url: str = getenv('S3_BUCKET_URL')
require_auth: str = getenv('REQUIRE_AUTH')

root_path: str = getenv("ROOT_PATH")
titiler_prefix: str = getenv("TITILER_PREFIX")
titiler_router_prefix: str = getenv("TITILER_ROUTER_PREFIX")

@lru_cache()
def get_settings():
Expand Down
12 changes: 9 additions & 3 deletions tiler/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
from titiler.core import TilerFactory
from titiler.core.errors import DEFAULT_STATUS_CODES, add_exception_handlers
from titiler.core.middleware import TotalTimeMiddleware, LoggerMiddleware

from .config.config import get_settings
from .middlewares.auth_middleware import AuthMiddleware
from .middlewares.url_injector import inject_s3_url

app = FastAPI(title="LandGriffon Tiler", root_path="/tiler")
root_path = get_settings().root_path
titiler_router_prefix = get_settings().titiler_router_prefix
titiler_prefix = get_settings().titiler_prefix

app = FastAPI(title="LandGriffon Tiler", docs_url='/tiler/docs')
app.add_middleware(TotalTimeMiddleware)
app.add_middleware(LoggerMiddleware)
app.add_middleware(AuthMiddleware)
Expand All @@ -15,8 +21,8 @@
allow_headers=["*"], )

# single COG tiler. One file can have multiple bands
cog = TilerFactory(router_prefix="/cog", path_dependency=inject_s3_url)
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"], prefix="/cog", )
cog = TilerFactory(router_prefix=titiler_router_prefix, path_dependency=inject_s3_url)
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"], prefix=titiler_prefix)
add_exception_handlers(app, DEFAULT_STATUS_CODES)


Expand Down

0 comments on commit 81763b1

Please sign in to comment.