All Projects → yanzhenjie → Andserver

yanzhenjie / Andserver

Licence: apache-2.0
🍒 Web server and web framework of Android platform.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Andserver

crab
🦀 a simple web server
Stars: ✭ 18 (-99.39%)
Mutual labels:  web-server, http-server
Facebooc
Yet another Facebook clone written in C
Stars: ✭ 483 (-83.53%)
Mutual labels:  http-server, web-server
httoop
HTTOOP - a fully object oriented HTTP protocol library written in python
Stars: ✭ 15 (-99.49%)
Mutual labels:  website, http-server
tinyweb
Simple and lightweight HTTP async server for micropython
Stars: ✭ 182 (-93.79%)
Mutual labels:  web-server, http-server
Fenix
A simple and visual static web server with collaboration features.
Stars: ✭ 1,559 (-46.83%)
Mutual labels:  http-server, web-server
sheret
A tiny, simple static file web server.
Stars: ✭ 45 (-98.47%)
Mutual labels:  web-server, http-server
Binserve
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. ⚡️🦀
Stars: ✭ 401 (-86.32%)
Mutual labels:  http-server, web-server
Nock Nock
🚪 Monitor and validate your websites to maintain maximum uptime.
Stars: ✭ 339 (-88.44%)
Mutual labels:  web-server, website
Hummingbird
Lightweight, flexible HTTP server framework written in Swift
Stars: ✭ 114 (-96.11%)
Mutual labels:  http-server, web-server
Mofuw
mofuw is *MO*re *F*aster, *U*ltra minimal *W*ebserver.
Stars: ✭ 107 (-96.35%)
Mutual labels:  http-server, web-server
tipi
Tipi - the All-in-one Web Server for Ruby Apps
Stars: ✭ 214 (-92.7%)
Mutual labels:  web-server, http-server
Servr
A simple HTTP server in R
Stars: ✭ 228 (-92.22%)
Mutual labels:  http-server, web-server
Kvantum
An intellectual (HTTP/HTTPS) web server with support for server side templating (Crush, Apache Velocity and JTwig)
Stars: ✭ 17 (-99.42%)
Mutual labels:  web-server, http-server
stirfry
StirFry is a self contained and lightweight web framework for nodejs
Stars: ✭ 24 (-99.18%)
Mutual labels:  web-server, http-server
Mongols
C++ high performance networking with TCP/UDP/RESP/HTTP/WebSocket protocols
Stars: ✭ 250 (-91.47%)
Mutual labels:  http-server, web-server
Caddy
Matthew Holt began developing Caddy in 2014 while studying computer science at Brigham Young University. (The name "Caddy" was chosen because this software helps with the tedious, mundane tasks of serving the Web, and is also a single place for multiple things to be organized together.) It soon became the first web server to use HTTPS automatically and by default, and now has hundreds of contributors and has served trillions of HTTPS requests.
Stars: ✭ 35,966 (+1126.67%)
Mutual labels:  http-server, web-server
Webapp.rs
A web application completely written in Rust. 🌍
Stars: ✭ 1,888 (-35.61%)
Mutual labels:  http-server, website
Catacumba
Asynchronous web toolkit for clojure built on top of Ratpack / Netty
Stars: ✭ 192 (-93.45%)
Mutual labels:  http-server, web-server
Narative.co
Narative builds brands, websites and products for growth-minded companies.
Stars: ✭ 226 (-92.29%)
Mutual labels:  website
Springmvc Mybatis Learning
SpringMVC 和 MyBatis 学习笔记,搭配示例,主要讲解一些基础的概念、用法和配置
Stars: ✭ 2,689 (-8.29%)
Mutual labels:  springmvc

AndServer

Logo

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:

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.

@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:

POST http://.../user/login
GET http://.../user/uid_001?fields=id,name,age
PUT http://.../user/uid_001

Get connection information with the client:

@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.

Reverse Proxy Server

Deploy a reverse proxy server:

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 :

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.yanzhenjie.andserver:plugin:2.1.9'
        ...
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}
...

And then add AndServer dependency to your module:

apply plugin: 'com.yanzhenjie.andserver'

...

dependencies {
    implementation 'com.yanzhenjie.andserver:api:2.1.9'
    annotationProcessor 'com.yanzhenjie.andserver:processor:2.1.9'
    ...
}

If you are using Kotlin, replace annotationProcessor with kapt.

Contributing

Before submitting pull requests, contributors must abide by the agreement .

License

Copyright 2021 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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].