Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.fitframework.example</groupId>
<artifactId>http-client</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>

<!-- FIT version -->
<fit.version>3.5.0-SNAPSHOT</fit.version>

<!-- Maven plugin versions -->
<maven.compiler.version>3.14.0</maven.compiler.version>
</properties>

<dependencies>
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-api</artifactId>
<version>${fit.version}</version>
</dependency>
<dependency>
<groupId>org.fitframework</groupId>
<artifactId>fit-util</artifactId>
<version>${fit.version}</version>
</dependency>
<dependency>
<groupId>org.fitframework.service</groupId>
<artifactId>fit-http-classic</artifactId>
<version>${fit.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.fitframework</groupId>
<artifactId>fit-build-maven-plugin</artifactId>
<version>${fit.version}</version>
<executions>
<execution>
<id>build-plugin</id>
<goals>
<goal>build-plugin</goal>
</goals>
</execution>
<execution>
<id>package-plugin</id>
<goals>
<goal>package-plugin</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.example.client;

import modelengine.fit.example.entity.Education;

import java.util.List;

/**
* This interface defines a set of methods for testing HTTP client proxy functionality.
* Each method corresponds to a specific HTTP request type and parameter binding scenario.
*
* @author 季聿阶
* @since 2025-06-01
*/
public interface TestInterface {
/**
* Tests request bean binding by sending an Education object in the request.
*
* @param education The Education object to be sent in the request.
* @return The modified Education object received in the response.
*/
Education requestBean(Education education);

/**
* Tests path variable binding by extracting a path variable from the URL.
*
* @param variable The path variable extracted from the URL.
* @return A string containing the path variable value.
*/
String pathVariable(String variable);

/**
* Tests header binding by extracting header values from the request.
*
* @param header The value of the "header" header.
* @param headers The list of values for the "headers" header.
* @return A string containing the header values.
*/
String header(String header, List<Integer> headers);

/**
* Tests cookie binding by extracting a cookie value from the request.
*
* @param cookieValue The value of the "cookie" cookie.
* @return A string containing the cookie value.
*/
String cookie(String cookieValue);

/**
* Tests query parameter binding by extracting a query parameter from the request.
*
* @param query The value of the "query" query parameter.
* @return A string containing the query parameter value.
*/
String query(String query);

/**
* Tests request body binding by extracting the request body content.
*
* @param requestBody The content of the request body.
* @return A string containing the request body content.
*/
String requestBody(String requestBody);

/**
* Tests form data binding by extracting a form field value from the request.
*
* @param form The value of the "form" form field.
* @return A string containing the form field value.
*/
String form(String form);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.example.client;

import modelengine.fit.example.entity.Education;
import modelengine.fit.http.annotation.GetMapping;
import modelengine.fit.http.annotation.HttpProxy;
import modelengine.fit.http.annotation.PatchMapping;
import modelengine.fit.http.annotation.PathVariable;
import modelengine.fit.http.annotation.PostMapping;
import modelengine.fit.http.annotation.PutMapping;
import modelengine.fit.http.annotation.RequestAddress;
import modelengine.fit.http.annotation.RequestBean;
import modelengine.fit.http.annotation.RequestBody;
import modelengine.fit.http.annotation.RequestCookie;
import modelengine.fit.http.annotation.RequestForm;
import modelengine.fit.http.annotation.RequestHeader;
import modelengine.fit.http.annotation.RequestMapping;
import modelengine.fit.http.annotation.RequestQuery;

import java.util.List;

/**
* This interface defines a set of methods for testing HTTP client proxy functionality.
* It extends the TestInterface and provides specific annotations for configuring the HTTP request details.
* The interface is marked with @HttpProxy to indicate it's a proxy for HTTP requests.
* The @RequestAddress annotation specifies the base URL and port for the requests.
* The @RequestMapping annotation sets the base path for all methods in this interface.
*
* @author 季聿阶
* @since 2025-06-01
*/
@HttpProxy
@RequestAddress(protocol = "http", host = "localhost", port = "8080")
@RequestMapping(path = "/http-server")
public interface TestRequestAddress extends TestInterface {
@Override
@PostMapping(path = "/request-bean")
Education requestBean(@RequestBean Education education);

@Override
@GetMapping(path = "/path-variable/{variable}")
String pathVariable(@PathVariable(name = "variable") String variable);

@Override
@GetMapping(path = "/header")
String header(@RequestHeader(name = "header") String header,
@RequestHeader(name = "headers") List<Integer> headers);

@Override
@GetMapping(path = "/cookie")
String cookie(@RequestCookie(name = "cookie") String cookieValue);

@Override
@GetMapping(path = "/query")
String query(@RequestQuery(name = "query") String query);

@Override
@PatchMapping(path = "/request-body")
String requestBody(@RequestBody String requestBody);

@Override
@PutMapping(path = "/form")
String form(@RequestForm(name = "form") String form);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.example.client;

import modelengine.fit.example.config.DefaultAddressLocator;
import modelengine.fit.example.entity.Education;
import modelengine.fit.http.annotation.GetMapping;
import modelengine.fit.http.annotation.HttpProxy;
import modelengine.fit.http.annotation.PatchMapping;
import modelengine.fit.http.annotation.PathVariable;
import modelengine.fit.http.annotation.PostMapping;
import modelengine.fit.http.annotation.PutMapping;
import modelengine.fit.http.annotation.RequestAddress;
import modelengine.fit.http.annotation.RequestBean;
import modelengine.fit.http.annotation.RequestBody;
import modelengine.fit.http.annotation.RequestCookie;
import modelengine.fit.http.annotation.RequestForm;
import modelengine.fit.http.annotation.RequestHeader;
import modelengine.fit.http.annotation.RequestMapping;
import modelengine.fit.http.annotation.RequestQuery;

import java.util.List;

/**
* This interface defines a set of methods for testing HTTP client proxy functionality.
* It extends the TestInterface and provides specific annotations for configuring the HTTP request details.
* The interface is marked with @HttpProxy to indicate it's a proxy for HTTP requests.
* The @RequestAddress annotation specifies the address locator class for the requests.
* The @RequestMapping annotation sets the base path for all methods in this interface.
*
* @author 季聿阶
* @since 2025-06-01
*/
@HttpProxy
@RequestAddress(address = DefaultAddressLocator.class)
@RequestMapping(path = "/http-server")
public interface TestRequestAddressClass extends TestInterface {
@Override
@PostMapping(path = "/request-bean")
Education requestBean(@RequestBean Education education);

@Override
@GetMapping(path = "/path-variable/{variable}")
String pathVariable(@PathVariable(name = "variable") String variable);

@Override
@GetMapping(path = "/header")
String header(@RequestHeader(name = "header") String header,
@RequestHeader(name = "headers") List<Integer> headers);

@Override
@GetMapping(path = "/cookie")
String cookie(@RequestCookie(name = "cookie") String cookieValue);

@Override
@GetMapping(path = "/query")
String query(@RequestQuery(name = "query") String query);

@Override
@PatchMapping(path = "/request-body")
String requestBody(@RequestBody String requestBody);

@Override
@PutMapping(path = "/form")
String form(@RequestForm(name = "form") String form);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.example.client;

import modelengine.fit.example.entity.Education;
import modelengine.fit.http.annotation.GetMapping;
import modelengine.fit.http.annotation.HttpProxy;
import modelengine.fit.http.annotation.PatchMapping;
import modelengine.fit.http.annotation.PathVariable;
import modelengine.fit.http.annotation.PostMapping;
import modelengine.fit.http.annotation.PutMapping;
import modelengine.fit.http.annotation.RequestBean;
import modelengine.fit.http.annotation.RequestBody;
import modelengine.fit.http.annotation.RequestCookie;
import modelengine.fit.http.annotation.RequestForm;
import modelengine.fit.http.annotation.RequestHeader;
import modelengine.fit.http.annotation.RequestMapping;
import modelengine.fit.http.annotation.RequestQuery;

import java.util.List;

/**
* This interface defines a set of methods for testing HTTP client proxy functionality.
* It extends the TestInterface and provides specific annotations for configuring the HTTP request details.
* The interface is marked with @HttpProxy to indicate it's a proxy for HTTP requests.
* The @RequestMapping annotation sets the base URL for all methods in this interface.
*
* @author 季聿阶
* @since 2025-06-01
*/
@HttpProxy
@RequestMapping(path = "http://localhost:8080/http-server")
public interface TestRequestAddressInClassMapping extends TestInterface {
@Override
@PostMapping(path = "/request-bean")
Education requestBean(@RequestBean Education education);

@Override
@GetMapping(path = "/path-variable/{variable}")
String pathVariable(@PathVariable(name = "variable") String variable);

@Override
@GetMapping(path = "/header")
String header(@RequestHeader(name = "header") String header,
@RequestHeader(name = "headers") List<Integer> headers);

@Override
@GetMapping(path = "/cookie")
String cookie(@RequestCookie(name = "cookie") String cookieValue);

@Override
@GetMapping(path = "/query")
String query(@RequestQuery(name = "query") String query);

@Override
@PatchMapping(path = "/request-body")
String requestBody(@RequestBody String requestBody);

@Override
@PutMapping(path = "/form")
String form(@RequestForm(name = "form") String form);
}
Loading