Skip to content

Enhance ResourceHttpRequestHandler with ResourceResolver strategy [SPR-10933] #15561

Closed

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-10933 and commented

Currently ResourceHttpRequestHandler uses a simple algorithm that takes the request path and tries to find a matching resource under one or more pre-configured locations, either under the web application root or on the classpath (e.g. under /META-INF/public-web-resources"). In order to implement more sophisticated resource serving, it should be possible to configure additional strategies for resolving the request path to a Resource, possibly even transforming the resource along the way.

A common use case is fingreprinting URLs to allow aggressive cache headers while still detecting changes when they occur (#14944). For this scenario to work a request path of "foo-e36d2e05253c6c7085a91522ce43a0b4.css" should resolve to resource "foo.css". The reverse should also be possible, i.e. a view should be able to look up the actual URL to use for "foo.css", e.g. "foo-e36d2e05253c6c7085a91522ce43a0b4.css".

Additional use cases include detecting gzipped files (extension ".gz") and serving them instead if the client accepts "gzip" content encoding, locating "css.less" files where ".css" is requested, etc.

In addition to locating resources, it should also be possible to transform resources. For example less-to-css transformation, gzipping, js/css minifying, etc.


Affects: 3.2.4

Issue Links:

3 votes, 10 watchers

Activity

  1. spring-projects-issues commented on Jun 26, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Christopher Smith commented

    This issue is marked as "complete", but the current 4.1.0.BUILD reference doc doesn't appear to discuss the new capabilities. Did I overlook it, or is it yet to be added?

  2. spring-projects-issues commented on Jun 26, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    Hi Christopher Smith - you're right, documentation is not there yet.
    We're using a sample project to test things out; do you have a special use case in mind or you'd just like to know how this works?

    Feedback is welcomed!

    Note that we're still validating all use cases and that the API should be fixed during the RC phase.

  3. spring-projects-issues commented on Jun 26, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Indeed there is no text summarizing the approach yet. The sample Brian referenced will be the basis for our SpringOne presentation so it is shows the end result albeit without the discussion. You can also have a look around the source code in the package where ResourceHttpRequestHandler is. You'll see the new abstractions there, their Javadoc should help too.

  4. spring-projects-issues commented on Jul 24, 2014

    @spring-projects-issues
    CollaboratorAuthor
  5. added
    type: enhancement
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions