公共服务-HTTP 请求日志

xielq 558230c5f9 init from phab 4 жил өмнө
src 558230c5f9 init from phab 4 жил өмнө
README.md 558230c5f9 init from phab 4 жил өмнө
pom.xml 558230c5f9 init from phab 4 жил өмнө

README.md

Http Log Module

Print logs of http request using spring aop

Instructions

  • Dependency

    <dependency>
    <groupId>com.uas.ps</groupId>
    <artifactId>ps-httplog</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    </dependency>
    
  • Configuration

    @EnableHttpLog
    public class Application {
    // code
    }
    
  • HTTP api

    @RestController
    @RequestMapping("/api")
    public class MyApi{
        
    @GetMapping("/test/{id}")
    @HttpLog(exclude = {"age"}, includeHeaders = {"name"}, excludeResult = true)
    public Map<String, Object> test(@PathVariable("id") int id, 
                                    @RequestParam("age") int age, 
                                    @RequestHeader("name") String name, 
                                    @RequestHeader("password") String password){
        Map<String, Object> result = new HashMap<>();
        result.put("id", id);
        result.put("age", age);
        result.put("name", name);
        result.put("password", password);
        return result;
    }
    }