In order to run the server in multiple environments, we need to support dynamic configuration via environment variables at the minimum.
Related Issues / PRs
Closes: #31
Thought Process
I imported https://github.com/kevinfalting/structconf for configuration management. This required creating a new config package and Config type, which I annotated with the appropriate struct tags.
I chose to name the environment variable PORT because that's a common env var that's set in providers like fly.io, although I couldn't find anything explicit about environment variables for the port, this may just be something we have to manually set.
I've also added the AllowedOrigins to the config, and we'll test that again once we're actually making requests from the client.
Overview
In order to run the server in multiple environments, we need to support dynamic configuration via environment variables at the minimum.
Related Issues / PRs
Closes: #31
Thought Process
I imported https://github.com/kevinfalting/structconf for configuration management. This required creating a new config package and Config type, which I annotated with the appropriate struct tags.
I chose to name the environment variable
PORT
because that's a common env var that's set in providers like fly.io, although I couldn't find anything explicit about environment variables for the port, this may just be something we have to manually set.I've also added the
AllowedOrigins
to the config, and we'll test that again once we're actually making requests from the client.Testing Steps
Run the server and then you can make a request:
Which you should get back a json of events.
You can override the default value by providing the environment variable:
You should see that it's listening on port
4545
.Run the curl again with the updated port, and get the same json result.
Risks
Since we're not testing the
AllowedOrigins
we may need to fix it when we begin adding the client side requests.Screenshots / Recordings
n/a