rest-template-interceptor

DESC

License

License

GroupId

GroupId

com.github.damianwajser
ArtifactId

ArtifactId

spring-commons-resttemplate-interceptor
Last Version

Last Version

1.10.3
Release Date

Release Date

Type

Type

jar
Description

Description

rest-template-interceptor
DESC
Project Organization

Project Organization

The Apache Software Foundation

Download spring-commons-resttemplate-interceptor

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.damianwajser/spring-commons-resttemplate-interceptor/ -->
<dependency>
    <groupId>com.github.damianwajser</groupId>
    <artifactId>spring-commons-resttemplate-interceptor</artifactId>
    <version>1.10.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.damianwajser/spring-commons-resttemplate-interceptor/
implementation 'com.github.damianwajser:spring-commons-resttemplate-interceptor:1.10.3'
// https://jarcasting.com/artifacts/com.github.damianwajser/spring-commons-resttemplate-interceptor/
implementation ("com.github.damianwajser:spring-commons-resttemplate-interceptor:1.10.3")
'com.github.damianwajser:spring-commons-resttemplate-interceptor:jar:1.10.3'
<dependency org="com.github.damianwajser" name="spring-commons-resttemplate-interceptor" rev="1.10.3">
  <artifact name="spring-commons-resttemplate-interceptor" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.damianwajser', module='spring-commons-resttemplate-interceptor', version='1.10.3')
)
libraryDependencies += "com.github.damianwajser" % "spring-commons-resttemplate-interceptor" % "1.10.3"
[com.github.damianwajser/spring-commons-resttemplate-interceptor "1.10.3"]

Dependencies

compile (3)

Group / Artifact Type Version
commons-io : commons-io jar 2.7
org.apache.commons : commons-lang3 jar 3.10
org.owasp.encoder : encoder jar 1.2.2

provided (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 2.3.0.RELEASE
org.springframework.boot : spring-boot-starter-validation jar 2.3.0.RELEASE

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.3.0.RELEASE

Project Modules

There are no modules declared in this project.

spring-commons

Overview

This project contains the general-purpose tools to spring. Project is licensed under Apache License 2.0.

Build Status Maven Central Maintainability alert_status coverage


Roadmap

Consult the proyect for details on the current spring-commons roadmap.

Get it!

Install

Maven

Functionality of this package is contained in Java package com.github.damianwajser, and can be used using following Maven dependency:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.0.RELEASE</version>
</parent>
<properties>
 ...
     <!-- Use the latest version whenever possible. -->
     <spring.commons>{lastversion}</spring.commons>
 ...
</properties>

<dependencies>
 ...
    <dependency>
        <groupId>com.github.damianwajser</groupId>
        <artifactId>spring-commons</artifactId>
        <version>${spring.commons}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
 ...
</dependencies>

Gradle

compile 'com.github.damianwajser:spring-commons:{lastVersion}'

Usage Create a spring-boot application.

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan(basePackages = {"com.github.damianwajser","{YOUR-PACKAGE}"})
public class Application {
   public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
   }
}

General configuration:

Key Value Module Reference
spring.jackson.property-naming-strategy PropertyNamingStrategy.SnakeCaseStrategy Spring web format JSON response when Object is return in a controller
spring.commons.app.name ${spring.commons.app.name} All spring-commons the name of microservice

Modules

1 spring-commons-exception

Collection of exceptions for the most common cases when rest apis are built, and override the http code.

In addition, they request additional information for errors.

They can be used on their own, or they are caught by spring-commons-exception-handler and this information is used to generate a nice error message.

For example:

Exception Http Code
BadRequestException 400
PaymentRequiredException 402
ForbiddenException 403
PermissionDeniedException 403
NotFoundException 404

2 spring-commons-rest-validation

This project override all annotations for standard JSR annotations.

Some annotations accept additional attributes like isNulleable, but the message and the bussisnessCode attributes are common to all of them.

Message: This is the message that will usually be rendered when the value of the respective property fails validation.

3 spring-commons-exception-handler

This module is responsible for generating error messages (REST) when an exception occurs, generating a unique interface for these occurrences. It is also in charge of correctly setting the HTTP codes in the message.

On the other hand, the internationalization option is enabled, for which in all the exceptions found in spring-commons-exceptions or the validations found in spring-commons-rest-validation We can enter placeholders when we talk about errors.

The language is selected by the client based on the header Accept-Lenguage: $ {locale} and this module will take it from the corresponding message.properties.

4 spring-commons-http-fixer

This project is in charge of solving the most common problems related to http codes in spring-mvc REST responses. Among other things, set the default http 201 code in the response when we are using the POST verb.

5 spring-commons-rest-templates

This project registers the RestTemplates to be used by the application.

At the same time, it incorporates an Interceptor to add custom headers (those that start with "X-"), to generate traceability between the microservices.

6 spring-commons-logger

This module generates useful tools for logging.

Among its features we find:

  • StatsFilter (generates a log with the duration for each request)
  • MDCFilter (it incorporates parameters in the MDC to be used in the loggin.pattern)
  • RequestIdGenerator (a UUID is generated for each request in order to have traceability)

7 spring-commons-logger-logstash

This module configures the connector to logstash async way.

8 spring-commons-cache

This module tries to solve the typical problems that we encounter when we use Redis as Cache in spring. Configure:

  • CacheManager
  • RedisTemplate

It also improves the lifetime of the keys when we use @Cacheable.

9 spring-commons-idempotency

This module tries to solve the problems associated with idempotence. For them, create a filter within the spring chain of responsibilities. When the first request is made, it saves in redis the request sent by the client associated with an idempotence key. When another request is made two things can happen:

  1. The first request finished executing, which returns the same response that was obtained in the first call.
  2. In case the first request is still running, a message will be returned indicating the conflict.

10 spring-commons-actuator

<plugin>
    <groupId>pl.project13.maven</groupId>
    <artifactId>git-commit-id-plugin</artifactId>
    <version>4.0.0</version>
    <executions>
        <execution>
            <id>get-the-git-info</id>
            <goals>
                <goal>revision</goal>
            </goals>
            <phase>initialize</phase>
        </execution>
    </executions>
    <configuration>
        <generateGitPropertiesFile>true</generateGitPropertiesFile>
        <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
        <commitIdGenerationMode>full</commitIdGenerationMode>
        <offline>true</offline>
    </configuration>
</plugin>

11 spring-commons-payment-utilities

Commons Issues:

DynamoDb

DynamoDb generate some issues connfiguring JPA:

@SpringBootApplication
@EnableDynamoDBRepositories(
    includeFilters = {
            @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
                {YOUR-REPO1}.class, {YOUR-REPO1}.class})
    }
)
@ComponentScan(basePackages = {"com.github.damianwajser","{YOUR-PACKAGE}"})
public class Application {
   public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
   }
}

License

The Spring Framework is released under version 2.0 of the Apache License.

Versions

Version
1.10.3
1.10.2
1.10.0
1.9.1
1.9.0
1.8.5
1.8.1
1.8.0
1.7.1
1.7.0
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.0
1.4.0
1.3.0
1.2.1
1.2.0
1.1.0
1.0.2
1.0.1
1.0.0
0.0.24
0.0.23