Skip to content

Commit

Permalink
modernizing carts app
Browse files Browse the repository at this point in the history
  • Loading branch information
initcron committed Oct 11, 2024
1 parent 096944f commit 427bc8f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Checkout the API Spec [here](http://microservices-demo.github.io/api/index?url=h

# Creating a dev environment

Platform : Ubuntu 16.04
Platform : Ubuntu 24.04

Setup Mongo DB
```
Expand Down Expand Up @@ -72,6 +72,8 @@ java -jar target/carts.jar

## Docker

Base Image for Docker Builds => maven:3.8-eclipse-temurin-21-alpine

`GROUP=weaveworksdemos COMMIT=test ./scripts/build.sh`

# Test
Expand Down
1 change: 1 addition & 0 deletions docker/carts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ COPY *.jar ./app.jar
RUN chown -R root:root ./app.jar

USER root
EXPOSE 8080
ENTRYPOINT ["java","-jar","./app.jar", "--port=8080"]
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletRe
private String getMatchingURLPattern(HttpServletRequest httpServletRequest) {
String res = "";
for (PatternsRequestCondition pattern : getUrlPatterns()) {
if (pattern.getMatchingCondition(httpServletRequest) != null &&
if (pattern != null && pattern.getMatchingCondition(httpServletRequest) != null &&
!httpServletRequest.getServletPath().equals("/error")) {
res = pattern.getMatchingCondition(httpServletRequest).getPatterns().iterator()
.next();
Expand All @@ -85,15 +85,23 @@ private String getMatchingURLPattern(HttpServletRequest httpServletRequest) {
private Set<PatternsRequestCondition> getUrlPatterns() {
if (this.urlPatterns == null) {
this.urlPatterns = new HashSet<>();
requestMappingHandlerMapping.getHandlerMethods().forEach((mapping, handlerMethod) ->
urlPatterns.add(mapping.getPatternsCondition()));
RepositoryRestHandlerMapping repositoryRestHandlerMapping = new
RepositoryRestHandlerMapping(mappings, repositoryConfiguration);
requestMappingHandlerMapping.getHandlerMethods().forEach((mapping, handlerMethod) -> {
PatternsRequestCondition condition = mapping.getPatternsCondition();
if (condition != null) {
urlPatterns.add(condition);
}
});

RepositoryRestHandlerMapping repositoryRestHandlerMapping = new RepositoryRestHandlerMapping(mappings, repositoryConfiguration);
repositoryRestHandlerMapping.setJpaHelper(jpaHelper);
repositoryRestHandlerMapping.setApplicationContext(applicationContext);
repositoryRestHandlerMapping.afterPropertiesSet();
repositoryRestHandlerMapping.getHandlerMethods().forEach((mapping, handlerMethod) ->
urlPatterns.add(mapping.getPatternsCondition()));
repositoryRestHandlerMapping.getHandlerMethods().forEach((mapping, handlerMethod) -> {
PatternsRequestCondition condition = mapping.getPatternsCondition();
if (condition != null) {
urlPatterns.add(condition);
}
});
}
return this.urlPatterns;
}
Expand Down

0 comments on commit 427bc8f

Please sign in to comment.