Webfilter-Resolver

Webfilter which enables automatic version resolution for /webjars/-Requests

Лицензия

Лицензия

Группа

Группа

org.webjars
Идентификатор

Идентификатор

webjars-webfilter-resolver
Последняя версия

Последняя версия

0.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Webfilter-Resolver
Webfilter which enables automatic version resolution for /webjars/-Requests
Ссылка на сайт

Ссылка на сайт

https://github.com/webjars/webfilter-resolver
Система контроля версий

Система контроля версий

https://github.com/webjars/webjars-webfilter-resolver

Скачать webjars-webfilter-resolver

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars/webjars-webfilter-resolver/ -->
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webjars-webfilter-resolver</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars/webjars-webfilter-resolver/
implementation 'org.webjars:webjars-webfilter-resolver:0.1.1'
// https://jarcasting.com/artifacts/org.webjars/webjars-webfilter-resolver/
implementation ("org.webjars:webjars-webfilter-resolver:0.1.1")
'org.webjars:webjars-webfilter-resolver:jar:0.1.1'
<dependency org="org.webjars" name="webjars-webfilter-resolver" rev="0.1.1">
  <artifact name="webjars-webfilter-resolver" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars', module='webjars-webfilter-resolver', version='0.1.1')
)
libraryDependencies += "org.webjars" % "webjars-webfilter-resolver" % "0.1.1"
[org.webjars/webjars-webfilter-resolver "0.1.1"]

Зависимости

provided (4)

Идентификатор библиотеки Тип Версия
javax.enterprise : cdi-api jar 1.2
javax.servlet : javax.servlet-api jar 3.1.0
org.slf4j : slf4j-api jar 1.7.22
org.webjars : webjars-locator-core jar 0.30

test (5)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-core jar 2.18.3
io.undertow : undertow-servlet jar 2.0.0.Final
org.webjars : bootstrap jar 4.1.0

Модули Проекта

Данный проект не имеет модулей.

Build Status Maven Central

webjars-webfilter-resolver

Webfilter which enables automatic resolving of webjars without versions.

Webjars automatically places the webjar dependency onto the classpath which allows referencing the asset files simply by including the file like webjars/bootstrap/4.1.0/css/bootstrap.min.css. However you have to include the version (4.1.0 in the previous snippet).

For Spring Boot, you can simply place the dependency webjars-locator in your pom.xml which will automatically resolve the versions.

This webfilter does the same for Java EE (or other web containers which implement the Servlet 3.1 API).

Features

This webfilter supports two response serve methods (behaviors).

Response Serve Method Explanation
REDIRECT Requests to webjars/foo/bar.js will be resolved by returning a redirection header. The request will automatically be redirected to webjars/foo/1.0.0/bar.js. Therefore, the files are resolved by two requests which happens automatically in the browser.
WRITE_BYTE_RESPONSE Default. The content of webjars/foo/1.0.0/bar.js will immediately be written to the output stream. No redirection takes place.

The mode WRITE_BYTE_RESPONSE is used by default. If you wish to override this behaviour, you can do so by supplying the configuration in the web.xml file. Here is an example:

    <filter-mapping>
        <filter-name>webjarFilter</filter-name>
        <url-pattern>/webjars/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>webjarFilter</filter-name>
        <filter-class>WebJarFilter</filter-class>
        <init-param>
            <param-name>responseServeMethod</param-name>
            <param-value>REDIRECT</param-value>
        </init-param>
    </filter>

If an invalid parameter value is used, the response serve method will fall back to WRITE_BYTE_RESPONSE and a warning log entry will be written to the server log.

Usage

To use this webfilter, two dependencies are necessary. First, the actual webfilter-resolver from this repository. Additionally, it expects a webjars-locator to be provided. The reason for that is that for specific application servers, a special webjar-locator is necessary. If this webfilter would include one of these locators by default, you would have to specifically exclude the locator from the dependency, if you are using a different application server than e.g. Wildfly.

Example for Wildfly

Following dependencies are required for the webfilter to work on a Wildfly server (tested with Wildfly 12 in Java EE 7 mode):

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webfilter-resolver</artifactId>
    <version>0.1.0</version>
</dependency>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webjars-locator-jboss-vfs</artifactId>
    <version>0.1.0</version><!-- The fact that the versions are equal is a coincidence :-) -->
</dependency>
org.webjars

WebJars

Web Libraries as JAR Files

Версии библиотеки

Версия
0.1.1