# maven
**Repository Path**: graceful-code/maven
## Basic Information
- **Project Name**: maven
- **Description**: 开源maven仓库,作者会将自己闲暇时间开发的框架或者工具放在这里供大家使用。
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-05-03
- **Last Updated**: 2024-01-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
### grace-api
简介:一款http请求代理框架,能够将重复冗余,不好管理的http请求代码简化,提升开发效率。
特性:\
1.以hutool http为后端框架\
2.通过调用java接口的方式去发送Http请求, 实现了业务逻辑与Http协议之间的解耦\
3.支持请求方法:GET, POST\
4.支持文件上传\
5.支持自定义拦截器\
6.支持自动签名处理\
7.支持缓存\
8.支持自动序列化\
9.支持异常降级处理\
10.支持全局或者单个客户端端日志级别设置以及超时配置。
##### 快速使用:
1.在pom.xml里面配置仓库地址
```
grace-project
https://gitee.com/graceful-code/maven/raw/master
```
2.引用依赖坐标
```
com.grace
grace-api
1.0.0-RELEASE
```
3.使用注解 @EnableGraceHttpProxyClients 开启http代理框架
```
@SpringBootApplication
@EnableGraceHttpProxyClients
public class GraceTestServiceApplication {
public static void main(String[] args) {
SpringApplication.run(GraceTestServiceApplication.class, args);
}
}
```
4.定义http代理接口
```
@GraceHttpClient(value = "test", fallback = HelloApiFallBack.class)
public interface HelloApi {
@GraceRequest(value = "/test", method = RequestMethod.POST)
Result hello(@RequestParam Integer code);
}
```
5.业务调用
```
@Resource
private HelloApi helloApi;
@GetMapping("/hello")
public Result test(@RequestParam Integer code){
return helloApi.hello(code);
}
```
6.放弃原来复杂冗余并且不好维护http调用方式
```
String json = JSONObject.toJsonString(user);
HttpResponse httpResponse = HttpRequest.post("http://localhost:8088/api//user")
.body(json)
.timeout(3000)
.execute();
if (httpResponse.isOk()){
String res = httpResponse.body();
return JSONObject.parseObject(res, Result.class);
}
return Result.builder().code(500).build();
```
###### 更多高级功能文档待后续添加。。。