Allow adding additional headers for Map/File resources - #862
Merged
TBlueF merged 3 commits intoSep 13, 2026
Conversation
nightowl286
reviewed
Sep 13, 2026
TBlueF
reviewed
Sep 13, 2026
Comment on lines
-221
to
252
| webRequestHandler.register(".*", new FileRequestHandler(webroot)); | ||
| webRequestHandler.register(".*", new FileRequestHandler(webroot, webserverConfig.getAdditionalHeaders())); | ||
|
|
||
| // map route | ||
| for (var mapConfigEntry : configManager.getMapConfigs().entrySet()) { | ||
| String id = mapConfigEntry.getKey(); | ||
| MapConfig mapConfig = mapConfigEntry.getValue(); | ||
|
|
||
| MapRequestHandler mapRequestHandler; | ||
| BmMap map = maps.get(id); | ||
| if (map != null) { | ||
| LivePlayersDataSupplier livePlayersDataSupplier = pluginConfig.isLivePlayerMarkers() ? | ||
| new LivePlayersDataSupplier(serverInterface, map.getWorld(), livePlayerInfoTransformer, pluginConfig.isHideDifferentWorld()) : | ||
| null; | ||
| LiveMarkersDataSupplier liveMarkersDataSupplier = new LiveMarkersDataSupplier(map.getMarkerSets()); | ||
|
|
||
| mapRequestHandler = new MapRequestHandler(map, livePlayersDataSupplier, liveMarkersDataSupplier, webserverConfig.isSseEnabled()); | ||
| mapRequestHandler = new MapRequestHandler( | ||
| map, | ||
| livePlayersDataSupplier, | ||
| liveMarkersDataSupplier, | ||
| webserverConfig.isSseEnabled(), | ||
| webserverConfig.getAdditionalHeaders() | ||
| ); | ||
| } else { | ||
| Storage storage = blueMap.getOrLoadStorage(mapConfig.getStorage()); | ||
| mapRequestHandler = new MapRequestHandler(storage.map(id)); | ||
| mapRequestHandler = new MapRequestHandler(storage.map(id), webserverConfig.getAdditionalHeaders()); | ||
| } | ||
|
|
||
| webRequestHandler.register( | ||
| "maps/" + Pattern.quote(id) + "/(.*)", | ||
| "$1", | ||
| new BlueMapResponseModifier(mapRequestHandler) | ||
| ); |
Member
There was a problem hiding this comment.
I think instead of adding the headers separately to each request-handler, maybe we can move the BlueMapResponseModifier from here up to the root (similar to how it's done here: c0999f7) and then we have to only pass it only to that one class which then takes care of adding them universally..
I would also be in favour of just removing both
response.addHeader("Cache-Control", "public");
response.addHeader("Cache-Control", "max-age=" + TimeUnit.DAYS.toSeconds(1));
completely in favour of adding them to the default config.
Or am i missing any issues that come with that?
TBlueF
reviewed
Sep 13, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow adding additional headers by config as mentioned in #833 (comment)
Some headers (ETag, Content-Type etc) which are calculated dynamically would break if overridden and cannot be modified.