# AndServer
![Logo](./images/logo.svg)
AndServer is an HTTP and reverse proxy server.
Web server and Web framework of Android platform. It provides annotations like SpringMVC, and if you are familiar with SpringMVC, you can master it very quickly.
- Static html website deployment.
- Dynamic http api deployment.
- Reverse proxy server.
## Web Server
Deploy a web server:
```java
Server server = AndServer.webServer(context)
.port(8080)
.timeout(10, TimeUnit.SECONDS)
.build();
// startup the server.
server.startup();
...
// shutdown the server.
server.shutdown();
```
It also has some features, such as `inetAddress(InetAddress)`, `serverSocketFactory(ServerSocketFactory)` and `sslContext(SSLContext)`, depending on what you want to achieve.
```java
@RestController
@RequestMapping(path = "/user")
public class UserController {
@PostMapping("/login")
public String login(@RequestParam("account") String account,
@RequestParam("password") String password) {
...
return "Successful.";
}
@GetMapping(path = "/{userId}")
public User info(@PathVariable("userId") String userId,
@QueryParam("fields") String fields) {
User user = findUserById(userId, fields);
...
return user;
}
@PutMapping(path = "/{userId}")
public void modify(@PathVariable("userId") String userId
@RequestParam("age") int age) {
...
}
}
```
The above code will generate the following two http apis:
```text
POST http://.../user/login
GET http://.../user/uid_001?fields=id,name,age
PUT http://.../user/uid_001
```
Get connection information with the client:
```java
@GetMapping(path = "/connection")
void getConnection(HttpRequest request, ...) {
request.getLocalAddr(); // HostAddress
request.getLocalName(); // HostName
request.getLocalPort(); // server's port
request.getRemoteAddr(); // HostAddress
request.getRemoteHost(); // Especially HostName, second HostAddress
request.getRemotePort(); // client's port
...
}
```
For documentation and additional information see [the website](https://yanzhenjie.com/AndServer).
## Reverse Proxy Server
Deploy a reverse proxy server:
```java
Server server = AndServer.proxyServer()
.addProxy("www.example1.com", "http://192.167.1.11:8080")
.addProxy("example2.com", "https://192.167.1.12:9090")
.addProxy("55.66.11.11", "http://www.google.com")
.addProxy("192.168.1.11", "https://github.com:6666")
.port(80)
.timeout(10, TimeUnit.SECONDS)
.build();
// startup the server.
server.startup();
...
// shutdown the server.
server.shutdown();
```
**Note**: It is just a reverse proxy and does not have the ability to take care of loading balance.
## Download
Add the plugin to your project build script :
```gradle
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.yanzhenjie.andserver:plugin:2.1.12'
...
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
...
```
And then add `AndServer` dependency to your module:
```gradle
apply plugin: 'com.yanzhenjie.andserver'
...
dependencies {
implementation 'com.yanzhenjie.andserver:api:2.1.12'
annotationProcessor 'com.yanzhenjie.andserver:processor:2.1.12'
...
}
```
If you are using Kotlin, replace `annotationProcessor` with `kapt`.
## Contributing
Before submitting pull requests, contributors must abide by the [agreement](./CONTRIBUTING.md) .
## License
```text
Copyright Zhenjie Yan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
没有合适的资源?快使用搜索试试~ 我知道了~
SpringMVC精品资源-- Web server and web framework of Android pl.zip
共241个文件
java:186个
png:11个
xml:9个
需积分: 5 0 下载量 200 浏览量
2024-02-18
12:51:54
上传
评论
收藏 426KB ZIP 举报
温馨提示
SpringMVC精品资源-- Web server and web framework of Android pl
资源推荐
资源详情
资源评论
收起资源包目录
SpringMVC精品资源-- Web server and web framework of Android pl.zip (241个子文件)
gradlew.bat 2KB
login.css 234B
.gitignore 127B
.gitignore 7B
.gitignore 6B
.gitignore 6B
.gitignore 6B
.gitignore 6B
config.gradle 1KB
build.gradle 884B
build.gradle 825B
build.gradle 437B
build.gradle 354B
build.gradle 334B
build.gradle 176B
settings.gradle 93B
gradlew 5KB
login.html 1KB
index.html 581B
gradle-wrapper.jar 52KB
ControllerProcessor.java 66KB
StringUtils.java 44KB
ObjectUtils.java 32KB
MediaType.java 25KB
MimeType.java 23KB
IOUtils.java 21KB
StandardRequest.java 17KB
CollectionUtils.java 17KB
ProxyServer.java 14KB
HttpRequest.java 14KB
Uri.java 13KB
Assert.java 12KB
MappingAdapter.java 12KB
Cookie.java 11KB
StandardMultipartResolver.java 11KB
DispatcherHandler.java 10KB
InterceptorProcessor.java 9KB
AssetsWebsite.java 9KB
ConfigProcessor.java 9KB
StatusCode.java 8KB
BasicServer.java 8KB
StandardCookieProcessor.java 8KB
HttpHeaders.java 8KB
OptionsHandler.java 8KB
ConverterProcessor.java 8KB
ResolverProcessor.java 8KB
LinkedCaseInsensitiveMap.java 7KB
Modified.java 7KB
ProxyHandler.java 7KB
TestController.java 7KB
DigestUtils.java 6KB
FileBrowser.java 6KB
CompoundComparator.java 6KB
MappingHandler.java 6KB
RequestWrapper.java 6KB
StandardSession.java 6KB
RequestMapping.java 6KB
StandardResponse.java 5KB
HttpResponse.java 5KB
StandardMultipartFile.java 5KB
Merge.java 5KB
ViewResolver.java 5KB
MainActivity.java 5KB
Server.java 4KB
BasicWebsite.java 4KB
StorageWebsite.java 4KB
BaseProcessor.java 4KB
StandardMultipartRequest.java 4KB
Session.java 4KB
LinkedMultiValueMap.java 4KB
Path.java 4KB
Constants.java 4KB
ServerManager.java 4KB
AndServerPlugin.java 4KB
CrossOrigin.java 4KB
InvertibleComparator.java 3KB
Multipart.java 3KB
MergeCrossOrigin.java 3KB
StandardStore.java 3KB
Utils.java 3KB
MultipartResolver.java 3KB
ResponseWrapper.java 3KB
ComponentRegister.java 3KB
MultipartRequest.java 3KB
ExceptionResolver.java 3KB
HttpDateFormat.java 3KB
Pair.java 3KB
MultipartFile.java 3KB
StandardSessionManager.java 3KB
LoginInterceptor.java 3KB
StandardIdGenerator.java 3KB
StreamBody.java 3KB
Addition.java 3KB
AppInfoGenerator.java 3KB
HttpMethod.java 3KB
Website.java 2KB
CoreService.java 2KB
StringBody.java 2KB
Executors.java 2KB
ReturnData.java 2KB
共 241 条
- 1
- 2
- 3
资源评论
码农阿豪
- 粉丝: 1w+
- 资源: 1754
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功