{"id":14983050,"url":"https://github.com/yanzhenjie/andserver","last_synced_at":"2025-05-14T12:12:23.461Z","repository":{"id":37430265,"uuid":"61079960","full_name":"yanzhenjie/AndServer","owner":"yanzhenjie","description":":cherries: Web server and web framework of Android platform.","archived":false,"fork":false,"pushed_at":"2023-06-07T08:04:09.000Z","size":6648,"stargazers_count":3780,"open_issues_count":140,"forks_count":770,"subscribers_count":111,"default_branch":"master","last_synced_at":"2025-04-11T05:00:47.846Z","etag":null,"topics":["android-server","http-server","springmvc","web-server","website"],"latest_commit_sha":null,"homepage":"https://yanzhenjie.com/AndServer","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yanzhenjie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-06-14T00:52:52.000Z","updated_at":"2025-04-10T13:01:54.000Z","dependencies_parsed_at":"2023-02-15T22:45:57.130Z","dependency_job_id":"33171e89-3aa3-46f0-a9c6-2d4df6aebaa9","html_url":"https://github.com/yanzhenjie/AndServer","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanzhenjie%2FAndServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanzhenjie%2FAndServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanzhenjie%2FAndServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanzhenjie%2FAndServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yanzhenjie","download_url":"https://codeload.github.com/yanzhenjie/AndServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140768,"owners_count":22021220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-server","http-server","springmvc","web-server","website"],"created_at":"2024-09-24T14:06:39.396Z","updated_at":"2025-05-14T12:12:18.272Z","avatar_url":"https://github.com/yanzhenjie.png","language":"Java","readme":"# AndServer\n\n![Logo](./images/logo.svg)\n\nAndServer is an HTTP and reverse proxy server.\n\nWeb 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.\n\n- Static html website deployment.\n- Dynamic http api deployment.\n- Reverse proxy server.\n\n## Web Server\n\nDeploy a web server:\n\n```java\nServer server = AndServer.webServer(context)\n    .port(8080)\n    .timeout(10, TimeUnit.SECONDS)\n    .build();\n\n// startup the server.\nserver.startup();\n\n...\n\n// shutdown the server.\nserver.shutdown();\n```\n\nIt also has some features, such as `inetAddress(InetAddress)`, `serverSocketFactory(ServerSocketFactory)` and `sslContext(SSLContext)`, depending on what you want to achieve.\n\n```java\n@RestController\n@RequestMapping(path = \"/user\")\npublic class UserController {\n\n    @PostMapping(\"/login\")\n    public String login(@RequestParam(\"account\") String account,\n                        @RequestParam(\"password\") String password) {\n\n        ...\n        return \"Successful.\";\n    }\n\n    @GetMapping(path = \"/{userId}\")\n    public User info(@PathVariable(\"userId\") String userId,\n                     @QueryParam(\"fields\") String fields) {\n\n        User user = findUserById(userId, fields);\n        ...\n\n        return user;\n    }\n\n    @PutMapping(path = \"/{userId}\")\n    public void modify(@PathVariable(\"userId\") String userId\n                       @RequestParam(\"age\") int age) {\n        ...\n    }\n}\n```\n\nThe above code will generate the following two http apis:\n\n```text\nPOST http://.../user/login\nGET http://.../user/uid_001?fields=id,name,age\nPUT http://.../user/uid_001\n```\n\nGet connection information with the client:\n\n```java\n@GetMapping(path = \"/connection\")\nvoid getConnection(HttpRequest request, ...) {\n    request.getLocalAddr();   // HostAddress\n    request.getLocalName();   // HostName\n    request.getLocalPort();   // server's port\n\n    request.getRemoteAddr();  // HostAddress\n    request.getRemoteHost();  // Especially HostName, second HostAddress\n    request.getRemotePort();  // client's port\n\n    ...\n}\n```\n\nFor documentation and additional information see [the website](https://yanzhenjie.com/AndServer).\n\n## Reverse Proxy Server\n\nDeploy a reverse proxy server:\n\n```java\nServer server = AndServer.proxyServer()\n    .addProxy(\"www.example1.com\", \"http://192.167.1.11:8080\")\n    .addProxy(\"example2.com\", \"https://192.167.1.12:9090\")\n    .addProxy(\"55.66.11.11\", \"http://www.google.com\")\n    .addProxy(\"192.168.1.11\", \"https://github.com:6666\")\n    .port(80)\n    .timeout(10, TimeUnit.SECONDS)\n    .build();\n\n// startup the server.\nserver.startup();\n\n...\n\n// shutdown the server.\nserver.shutdown();\n```\n\n**Note**: It is just a reverse proxy and does not have the ability to take care of loading balance.\n\n## Download\n\nAdd the plugin to your project build script :\n\n```gradle\nbuildscript {\n    repositories {\n        google()\n        mavenCentral()\n    }\n\n    dependencies {\n        classpath 'com.yanzhenjie.andserver:plugin:2.1.12'\n        ...\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n}\n...\n```\n\nAnd then add `AndServer` dependency to your module:\n\n```gradle\napply plugin: 'com.yanzhenjie.andserver'\n\n...\n\ndependencies {\n    implementation 'com.yanzhenjie.andserver:api:2.1.12'\n    annotationProcessor 'com.yanzhenjie.andserver:processor:2.1.12'\n    ...\n}\n```\n\nIf you are using Kotlin, replace `annotationProcessor` with `kapt`.\n\n## Contributing\n\nBefore submitting pull requests, contributors must abide by the [agreement](./CONTRIBUTING.md) .\n\n## License\n\n```text\nCopyright Zhenjie Yan\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanzhenjie%2Fandserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanzhenjie%2Fandserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanzhenjie%2Fandserver/lists"}