Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: introduce middlewares #23

Merged
merged 12 commits into from
Feb 6, 2025

Conversation

pvbouwel
Copy link
Contributor

As a first change this will introduce middleware for logging.

Introduce a middleware for logging. The goal of this middleware is to make sure access logging is possible so for accuracy it is best to have it as entry point so even before any router.

Because health checking requires special care for logging this middleware also has health checking as responsibilty. The same middleware is used for sts and s3 components.

Peter Van Bouwel added 12 commits January 30, 2025 13:57
Introduce a middleware for logging. The goal of this middleware is to make sure access logging is possible so for accuracy it is best to have it as entry point so even before any router.

Because health checking requires special care for logging this middleware also has health checking as responsibilty.  The same middleware is used for sts and s3 components.
Make sure the bytes sent received and the status code are updated such that the access log shows the values that are to be expected.
Using stringer allows to track operations easily in Request context and it is also very execution efficient.
While this initially makes the register route functions uglier we can clean it up later in a refactor. Things will become messier and uglier before they become prettier.
The cmd package was just a 'dump nearly everything' package. One of the problems of this was tight coupling and not allowing for re-usable parts. This refactor is a starting point. By no means perfect and likley there are way too many public objects but it does help to decouple parts and avoid certain duplication of code.
When relative paths are provided in the backendconfig file they should be relative to the config file and not to the working directory. Absolute paths are just treated as is.

Also allow inline credentials to not overcomplicate creation of test files for test setups.
…ivate key as argument

tests: update presign_test's to work post code restructure

refactor: make sure IsPresignedUrlWithValidSignature also communicates information regarding expiry.
Introduce AWS error codes in order to allow to create re-usable code and have an interface that is not service specific.

feature: user facing errors. Allow passing error which can be user facing. VITObelgium#19
…port 8443 already in use)

bugfix: When awaiting health it should actually shut down the server if not healthy after a while.
@pvbouwel pvbouwel merged commit 21bfb75 into VITObelgium:main Feb 6, 2025
5 checks passed
@pvbouwel pvbouwel deleted the refactor/middleware_for_logging branch February 6, 2025 18:15
@pvbouwel
Copy link
Contributor Author

pvbouwel commented Feb 6, 2025

This resolves #19 by adding a package usererror which allows creating an error that is aware of user facing messaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant