克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MPL-2.0

MicroRest

MircoRest是一款基于okhttp构建的 http客户端请求框架,优雅适配了微服务请求,它能够将 HTTP 的所有请求信息(包括 URL、Header 以及 Body 等信息)绑定到您自定义的 Interface 方法上,支持上下文穿透、请求参数动态修改,SSE请求支持,能够通过调用本地接口方法的方式发送 HTTP 请求。

其设计思想基于动态代理。

特性

  • 自动类型转化,接口返回值自动转化为函数接收对象类型(使用Map fillBean)

  • 传统HTTP 请求支持, @Get @Post @Put @Delete 支持

  • 文件上传支持(MultipartFile或本地文件)

  • 微服务请求支持,@MicroGet @MicroPost @MicroPut @MicroDelete 支持,默认支持 NacOS,支持自定义拓展

  • SSE请求支持,@SseGet @SsePost支持,类GPT请求实现转发

  • 请求参数自定义,@PathVar 自定义路径参数 , @Query 自定义查询参数

  • 请求头自定义 ,@Headers 请求头支持,多种构建方式

  • 请求体自定义, @Body 请求体支持,多种构建方式

  • 自定义请求客户端 MicroRestClient

  • 支持装饰器模式 ,传递请求头和请求体

  • 请求超时配置

安装配置

安装

需要配置 jitpack作为镜像源,在pom文件中引入

<!--jitpack-->
<repositories>
   <repository>
       <id>jitpack.io</id>
       <url>https://www.jitpack.io</url>
   </repository>
</repositories>

引入 micro-rest 依赖,版本号查看右侧发行版版本

<!--微服务请求-->
<dependency>
   <groupId>com.gitee.lboot</groupId>
   <artifactId>micro-rest</artifactId>
   <version>${version}</version>
</dependency>

配置

该框架默认支持并实现了基于 nacos的微服务发现机制,需要配置如下

不需要引入 nacos 依赖,是基于 openAPI 构建实现

#################### 服务注册发现 #######################
nacos.discovery.server-addr=127.0.0.1:8848
nacos.discovery.auto-register=true
nacos.discovery.enabled=true

支持拓展其他的服务发现,只需要自定义拓展实现ServiceResolution

快速上手

开放接口提供文章: https://juejin.cn/post/7041461420818432030

对于需要自定义的接口,需要用 @MicroRest标记为需要动态代理实现的接口,程序编译时会自动构建对应的请求方法。对于请求返回的结果,程序会自动读取接口参数类型并构建转化函数实现数据的转化。

请求地址构建

构建一个请求,最重要的是请求地址的构建,如下注解实现了请求路径参数和查询参数的构建

@PathVar

路径参数构建

@PathVar("key") 可以指定路径参数名称,如果没有指定,则按照当前参数实际名称进行替换,例如下图两种定义方式都可以。

@MicroRest
public interface TestPostApi {
    @Get("http://jsonplaceholder.typicode.com/posts/{id}")
    PostVO getPost(@PathVar Long id);
    
    @Get("http://jsonplaceholder.typicode.com/posts/{id}")
    PostVO getPost(@PathVar("id") Long xx);
}

@Query

查询参数构建

其参数替换有如下规则:

  1. 指定参数为基础数据类型(原子性数据,不可再分割,例如 Integer, Long, String ),支持使用@Query("key") 指定参数名称,或使用 @Query 使用当前参数实际名称,下面两种定义方式效果一致。

    @MicroRest
    public interface TestPostApi {
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Query("userId") Long xx);
        
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Query Long userId);
    }
    
  2. 指定参数非基础数据类型,例如Map,用户自定义类, 仅支持 @Query,支持自动转化参数,下面定义效果与上面一致。

    用户自定义查询参数

    class QueryParams{
    	String userId;
    }
    
    @MicroRest
    public interface TestPostApi {
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Query QueryParams params);
    }
    

#{}

模板内容替换

目前仅支持读取application.properties配置文件中的配置项的值,并实现替换

application.properties

openai.chat.host=https://api.openai-proxy.com
@MicroRest
public interface MicroRestChatApi {
    @SsePost(value = "#{openai.chat.host}/v1/chat/completions", converter = ChatConverter.class)
    StreamResponse chatCompletions(@Headers Map<String, Object> headers, @Body Map<String,Object> params);

}

请求头构建

@Headers

请求头信息构建

其参数替换有如下规则:

  1. 指定参数为基础数据类型(原子性数据,不可再分割,例如 Integer, Long, String ),支持使用@Headers("key") 指定参数名称,或使用 @Headers 使用当前参数实际名称,下面两种定义方式效果一致。

    @MicroRest
    public interface TestPostApi {
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Headers("token") String token);
        
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Headers String token);
    }
    
  2. 指定参数非基础数据类型,例如Map,用户自定义类, 仅支持 @Headers,支持自动转化参数,下面定义效果与上面一致。

    自定义实体类

    class CustomHeaders{
    	String token = "xxx";
    }
    

    Map

    {
    	"Content-Type":"application/x-www-form-urlencoded"
    }
    

    使用举例

    @MicroRest
    public interface TestPostApi {
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Headers CustomHeaders headers);
        
        @Get("http://jsonplaceholder.typicode.com/posts")
        List<PostVO> getPosts(@Headers Map<String,Object> headers);
    }
    
  3. 原子性数据参数优先级大于自定义类或Map, 会覆盖其中的数据。

@Anno headers

例如@Get, @MicroPost等一些列注解,都支持请求头参数配置,其配置形式如下:

@MicroRest
public interface TestPostApi {
    @Post(url = "http://jsonplaceholder.typicode.com/posts",
    headers = {
           "Content-Type:application/x-www-form-urlencoded;charset=utf-8"
    })
    PostVO createPost(@Headers Map<String,Object> headers);
}

这种方式一般用于固定数值的请求头,需要动态变化的,采用上面的方式进行组装。

支持模板替换,自动匹配替换application.properties指定的数据项

    @SsePost(value = "#{openai.chat.host}/v1/chat/completions",
            headers = {"Authorization:Bearer #{openai.chat.key}"},
            converter = ChatConverter.class)
    StreamResponse chatCompletions(@Body Map<String,Object> params);

其中 headers = {"Authorization:Bearer #{openai.chat.key}"}就是模板请求头用法

请求体构建

@Body

请求体构建

该参数用法和@Query, @Headers 都很相似

  1. 指定参数为基础数据类型(原子性数据,不可再分割,例如 Integer, Long, String ),支持使用@Body("key") 指定参数名称,或使用 @Body 使用当前参数实际名称。

  2. 指定参数非基础数据类型,例如Map,用户自定义类, 仅支持 @Body,支持自动转化参数。

  3. 原子性数据参数优先级大于自定义类或Map, 会覆盖其中的数据。

    @MicroRest
    public interface TestPostApi {
        @Post("http://jsonplaceholder.typicode.com/posts")
        Object createPost(@Body PostVO postVO);
    }
    

请求透传

@Decorator

请求透传

被该注解标记的方法,会根据配置属性,自动读取请求上下文中的请求头和请求体

@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Decorator {
    // 是否读取请求头
    boolean withHeader() default true;
    
    // 是否读取请求体
    boolean withBody() default true;
    
    // 装饰器默认实现 --> 请求头和请求体读取,支持自定义
    Class<? extends ProxyContextDecorator> value() default DefaultProxyContextDecorator.class;
}

自定义

通过继承抽象类 ProxyContextDecorator并重写方法实现,在使用注解时指定自定义实现类

public abstract class ProxyContextDecorator{
    public Map<String,Object> readHeader(){
        HashMap<String,Object> header = new HashMap<>();
        HttpServletRequest request =((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()){
            String headerName = headerNames.nextElement();
            header.put(headerName,request.getHeader(headerName));
        }
        return header;
    }
    public Map<String,Object> readBody(){
        HashMap<String,Object> body = new HashMap<>();
        HttpServletRequest request =((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        Enumeration<String> bodyNames = request.getParameterNames();
        while (bodyNames.hasMoreElements()){
            String paramKey = bodyNames.nextElement();
            body.put(paramKey,request.getParameter(paramKey));
        }
        return body;
    }
}

响应拦截

@ResponseHandler

响应拦截

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ResponseHandler {
    // 拦截处理器默认实现 --> 
    Class<? extends ProxyResponseHandler> value() default ProxyResponseHandler.class;
}

自定义

通过继承抽象类 ProxyResponseHandler并重写方法实现,在使用注解时指定自定义实现类

public abstract class ProxyResponseHandler{
    public String onSuccess(String body){
        return body;
    }

    @SneakyThrows
    public MicroRestException onFailure(Response response){
        String message = null;
        if (response.body() != null) {
            message = response.body().string();
        }
        if (Validator.isEmpty(message)){
            message = response.message();
        }
        Integer code = response.code();
        return new MicroRestException(code,message);
    }
}

文件上传支持

通过对 @Post,@MicroPost请求头配置实现

  1. 请求头配置为 Content-Type:multipart/form-data
   @Post(value = "#{openai.chat.host}/v1/files",headers = {
            "Content-Type:multipart/form-data",
            "Authorization: Bearer #{openai.chat.key}"
    })
    Map<String,Object> uploadFile(@Body ChatFileParams params);
  1. 参数支持MultipartFileFile
@Data
public class ChatFileParams {
    File file;
    
    String purpose;
}
@Data
public class ChatFileParams {
    MultipartFile file;
    
    String purpose;
}

如果没有其余附加信息,可以只上传文件

   @Post(value = "http://localhost:8080/v1/files",headers = {
            "Content-Type:multipart/form-data",
    })
    Map<String,Object> uploadFile(@Body("fileKey") File file);
   @Post(value = "http://localhost:8080/v1/files",headers = {
            "Content-Type:multipart/form-data",
    })
    Map<String,Object> uploadFile(@Body("fileKey") MultipartFile file);

REST请求支持

@Post

作用域:方法

@Put

作用域:方法

@Get

作用域:方法

@Delete

作用域:方法

注解属性

上述注解注解属性一致:

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface XXX {
    @AliasFor("url")
    String value() default "";

    @AliasFor("value")
    String url() default "";
	// 默认请求头配置
    String[] headers() default {};
    // 超时时间配置
    int connectTimeout() default 10;
    int readTimeout() default 10;
    int writeTimeout() default 10;

}

微服务请求支持

@MicroPost

作用域:方法

@MicroPut

作用域:方法

@MicroGet

作用域:方法

@MicroDelete

作用域:方法

注解属性

上述注解属性项一致

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MicroXXX {
    // 分组名称,不传递则为默认分组
    String groupName() default "";
    // 微服务名称
    String serviceName() default "";

    // 请求路径
    String path() default "";

    // 请求头信息
    String[] headers() default {};

}

基础使用

项目已经基于OpenApi实现了对NacOS微服务请求的支持,指定服务名称,构建请求时,会自动将服务名称置换为对应的请求地址

@MicroRest
public interface AuthApi {
    @MicroGet(serviceName = "auth-hrm",path = "/system/user/info")
    AuthInfo getUserInfo(@Headers("token") String token);


    @MicroGet(serviceName = "auth-hrm", path = "/system/users/{id}")
    List<Object> getUserById(@PathVar("id") String id);
}

自定义服务解析

通过继承实现 ServiceResolution 接口,可以适配多种服务注册发现中心,以本项目默认实现举例:

NacosServiceResolution.java

SSE请求支持

MicroRest实现了对SSE请求的支持,限制返回类型必须为StreamResponse

一文读懂即时更新方案:SSE - 掘金 (juejin.cn)

ChatGPT请求转发为例

@MicroRest
public interface MicroRestChatApi {
    @SsePost(value = "#{openai.chat.host}/v1/chat/completions", converter = ChatConverter.class)
    StreamResponse chatCompletions(@Headers Map<String, Object> headers, @Body Map<String,Object> params);

}

Controller 写法

MicroRestChatApi microRestChatApi;
@GetMapping(value = "stream/chat/{chatId}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@ApiOperation(value = "流聊天")
@SneakyThrows
public StreamResponse doStreamChat(@PathVariable("chatId") String chatId){
     // 构建请求头和请求体
     return microRestChatApi.chatCompletions(headers, paramMap);
}

@SsePost

作用域: 方法

@SseGet

作用域:方法

注解属性

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SseXXX {
    @AliasFor("url")
    String value() default "";

    @AliasFor("value")
    String url() default "";

    String[] headers() default {};

    // 终止信号
    String signal() default "DONE";
    
    // 信息类型转换默认实现类
    Class<? extends SseMessageConverter> converter() default DefaultSseMessageConverter.class;
    
    // 超时时间配置
    int connectTimeout() default 10;
    int readTimeout() default 600;
    int writeTimeout() default 50;

}

@SseSocketId

类似 @PathVar用法,不需要指定内部参数

作用域:参数

SSE请求需要指定信道ID,如果没有指定则自动构建随机信道ID

@MicroRest
public interface MicroRestChatApi {
    @SsePost(value = "#{openai.chat.host}/v1/chat/completions", converter = ChatConverter.class)
    StreamResponse chatCompletions(@Headers Map<String, Object> headers, @Body Map<String,Object> params, @SseSocketId String socketId);
}

Sse Hook

监听钩子

通过拓展实现对应服务实现对应的业务逻辑

public interface SseHookService {
    /**
     * 监听连接状态做对应处理
     * @param socketId
     */
    void onConnect(String socketId);

    /**
     * 监听连接错误状态做处理
     * @param socketId
     */
    void onError(String socketId);

    /**
     * 监听完成状态做对应处理
     * @param socketId
     * @param msg
     */
    void onCompletion(String socketId,String msg);

}

Sse Event

通过Hook可以实现对SSE状态的监听处理,除此之外,提供了事件驱动的方式实现监听(高度解耦),目前支持了消息完成监听

SseMessageCompleteEvent

SSE通信完成事件,msg为最后全部数据流经SseMessageConverter转化后组成的完整内容

@Slf4j
@Getter
public class SseMessageCompleteEvent extends ApplicationEvent {
    String msg;
    public SseMessageCompleteEvent(Object source, String msg) {
        super(source);
        this.msg = msg;
    }

    public SseMessageCompleteEvent(Object source, Clock clock) {
        super(source, clock);
    }
}

监听示例

可以设置 @Async异步处理

@Slf4j
@Component
public class MicroRestTestListener {
    // @Async
    @EventListener(SseMessageCompleteEvent.class)
    public void SseMessageCompleteEventListener(SseMessageCompleteEvent event){
        String msg = event.getMsg();
        log.info("SSE传送消息为:{}", msg);
    }
}

请求客户端

基于okhttp构建请求比较复杂,基于okhttp封装MircoRestClient,可以非常方便的构建请求,实现用户自己的自定义请求。

用法举例:

Response response = new MicroRestClient()
                    .url("http://localhost:8001")
                    .addQuery("serviceName",serviceName)
                    .addQuery("groupName", groupName)
                    .execute();
ResponseBody responseBody = response.body();

支持方法:

方法 备注 返回结果
header(Map<String,Object> header) 设置请求头 MicroRestClient
addHeader(String key, Object val) 设置请求头 MicroRestClient
body(Map<String,Object> body) 设置请求体 MicroRestClient
addBody(String key, Object val) 设置请求体 MicroRestClient
query(Map<String,Object> query) 设置请求参数 MicroRestClient
addQuery(String key, Object val) 设置请求参数 MicroRestClient
method(HttpMethod httpMethod) 设置请求方法 MicroRestClient
method(String method) 设置请求方法 MicroRestClient
url(String url) 设置请求地址 MicroRestClient
sse() 设置开启SSE MicroRestClient
execute() 请求执行 Response:okhttp3
getRequest() 获取当前请求信息 Request:okhttp3
Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.

简介

使用注解的方式快速构建微服务/HTTP请求接口,基于动态代理和反射实现 展开 收起
Java
MPL-2.0
取消

发行版 (9)

全部
7个月前

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化