Skip to content

Commit d0ed4c8

Browse files
authored
Add web url prefix using application properties (#100)
* Add web url prefix using application properties * Added change log
1 parent d8b3720 commit d0ed4c8

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# [Rqueue] New and Notable Changes
22

3+
### [2.8.1] - 19-Jul-2021
4+
5+
Option to add rqueue web url prefix, the prefix is configured from application.properties file using
6+
`rqueue.web.url.prefix=my-application`, now rqueue dashboard would be served
7+
at `my-application/rquque` instead of `/rqueue`, the configuration has higher priority than the
8+
HTTP request header `x-forwarded-prefix`.
9+
310
### [2.8.0] - 08-Jun-2021
411

512
### Fixes
@@ -13,12 +20,11 @@
1320
### Added
1421

1522
* Pause/Unpause queue from dashboard
16-
* Pause/Unpause queue programatically
23+
* Pause/Unpause queue programatically
1724
* Batch message fetching
1825
* Default queue priority to WEIGHTED
1926
* Added an API to update the visibility timeout of running job
2027

21-
2228
## [2.7.0] - 13-Apr-2021
2329

2430
### Fixes
@@ -244,3 +250,5 @@ Fixes:
244250
[2.7.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.7.0-RELEASE
245251

246252
[2.8.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.8.0-RELEASE
253+
254+
[2.8.0]: https://repo1.maven.org/maven2/com/github/sonus21/rqueue-core/2.8.1-RELEASE

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ext {
7070

7171
subprojects {
7272
group = 'com.github.sonus21'
73-
version = '2.8.0-RELEASE'
73+
version = '2.8.1-RELEASE'
7474

7575
dependencies {
7676
// https://mvnrepository.com/artifact/org.springframework/spring-messaging
-909 Bytes
Loading

rqueue-core/src/main/java/com/github/sonus21/rqueue/config/RqueueWebConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ public class RqueueWebConfig {
2929
* Control whether web app is enabled or not. If it's marked false then it will throw HTTP 503
3030
* (Service unavailable) error.
3131
*/
32-
3332
@Value("${rqueue.web.enable:true}")
3433
private boolean enable;
3534

35+
@Value("${rqueue.web.url.prefix:}")
36+
private String urlPrefix;
37+
3638
@Value("${rqueue.web.max.message.move.count:1000}")
3739
private int maxMessageMoveCount;
3840

rqueue-core/src/main/java/com/github/sonus21/rqueue/web/controller/ReactiveRqueueViewController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.github.sonus21.rqueue.config.RqueueConfig;
2020
import com.github.sonus21.rqueue.config.RqueueWebConfig;
2121
import com.github.sonus21.rqueue.utils.ReactiveEnabled;
22+
import com.github.sonus21.rqueue.utils.StringUtils;
2223
import com.github.sonus21.rqueue.web.service.RqueueViewControllerService;
2324
import java.util.Locale;
2425
import org.springframework.beans.factory.annotation.Autowired;
@@ -57,7 +58,11 @@ public ReactiveRqueueViewController(
5758
}
5859

5960
private String xForwardedPrefix(ServerHttpRequest request) {
60-
return request.getHeaders().getFirst("x-forwarded-prefix");
61+
String prefix = rqueueWebConfig.getUrlPrefix();
62+
if (StringUtils.isEmpty(prefix)) {
63+
return request.getHeaders().getFirst("x-forwarded-prefix");
64+
}
65+
return prefix;
6166
}
6267

6368
@GetMapping

rqueue-core/src/main/java/com/github/sonus21/rqueue/web/controller/RqueueViewController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.github.sonus21.rqueue.config.RqueueWebConfig;
2020
import com.github.sonus21.rqueue.utils.ReactiveDisabled;
21+
import com.github.sonus21.rqueue.utils.StringUtils;
2122
import com.github.sonus21.rqueue.web.service.RqueueViewControllerService;
2223
import com.mitchellbosecke.pebble.spring.servlet.PebbleViewResolver;
2324
import java.util.Locale;
@@ -53,7 +54,11 @@ public RqueueViewController(
5354
}
5455

5556
private String xForwardedPrefix(HttpServletRequest request) {
56-
return request.getHeader("x-forwarded-prefix");
57+
String prefix = rqueueWebConfig.getUrlPrefix();
58+
if (StringUtils.isEmpty(prefix)) {
59+
return request.getHeader("x-forwarded-prefix");
60+
}
61+
return prefix;
5762
}
5863

5964
@GetMapping

rqueue-core/src/main/resources/META-INF/spring-configuration-metadata.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@
289289
"type": "java.lang.Boolean",
290290
"defaultValue": true
291291
},
292+
{
293+
"sourceType": "com.github.sonus21.rqueue.config.RqueueWebConfig",
294+
"name": "rqueue.web.url.prefix",
295+
"description": "Rqueue web url path prefix",
296+
"type": "java.lang.String",
297+
"defaultValue": null
298+
},
292299
{
293300
"sourceType": "com.github.sonus21.rqueue.config.RqueueWebConfig",
294301
"name": "rqueue.web.max.message.move.count",

0 commit comments

Comments
 (0)