Skip to content

jsalonl/interceptor-springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Springboot Custom Interceptor

Description

Custom interceptor to obtain a detailed log of the application's requests and responses and simple error handling.

Structure of project

.
├── dto                    	# DTO example (Request and Response)
├── exception			# Exception Handler
│   ├── controller          	# Rest Advice Controller
│   ├── dto         		# DTO response for exception handling
├── interceptor         	# Interceptor config
│   ├── dto         		# Logger DTO
│   ├── service         	# Service to log trace
├── web				# Rest Controller

Parameters to trace

  • method : { GET, POST, PUT, PATCH, OPTIONS, DELETE }
  • ip : Request Ip Adrress
  • path : Request URI
  • parametersIn : Parameters of request (@RequestBody or @RequestParam)
  • parametersOut : Body of response
  • codeResponse : HTTP status
  • timeResponse : Response time of service

Defaults values

How to use

  1. Clone repository.
  2. Open folder.
  3. Run:
    mvn clean && mvn install
    
  4. Open in your favorite IDE (I use Intellij Idea).
  5. Use postman or SoapUI to test.

Outputs and screenshots

An example of output.

LOG{
	"method":"DELETE",
	"ip":"127.0.0.1",
	"path":"/interceptor/v1/test",
	"parametersIn":{},
	"parametersOut":
		{
			"code":"400","message":"Missing parameter: id"
		},
	"codeResponse":400,
	"timeResponseService":"69 ms"
}

Do you want to support me?


Buy Me A Coffee

About

Custom Log Interceptor for springboot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages