https://github.com/kenta-shimizu/httpjava8
https://github.com/kenta-shimizu/httpjava8
http
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/kenta-shimizu/httpjava8
- Owner: kenta-shimizu
- License: apache-2.0
- Created: 2019-07-10T11:19:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-21T13:44:05.000Z (over 5 years ago)
- Last Synced: 2025-02-10T14:52:53.830Z (about 1 year ago)
- Topics: http
- Language: Java
- Size: 139 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpjava8
## Introduction
This library is template of Http Server that runs only on Java8+.
Use to create simple API HTTP Server.
## for HTTP Server
### Open General HTTP Server
```
final HttpVersion1p1AsynchronousSocketChannelServerConfig serverConfig = new HttpVersion1p1AsynchronousSocketChannelServerConfig();
serverConfig.addBind(new InetSocketAddress("127.0.0.1", 8080));
final GeneralFileHttpVersion1p1ServerServiceConfig generalFileConfig = new GeneralFileHttpVersion1p1ServerServiceConfig();
generalFileConfig.serverName("HTTP-GENERAL-SERVER");
generalFileConfig.serverRoot(Paths.get("/path/to/root-directory"));
generalFileConfig.addDirectoryIndexFile("index.html");
HttpServer server = new HttpVersion1p1AsynchronousSocketChannelServer(serverConfig);
server.addServerService(new GeneralFileHttpVersion1p1ServerService(generalFileConfig));
server.open();
```
See also ["/src/examples/example1/ExampleHttpGeneralServer.java"](/src/examples/example1/)
### Create API HTTP Server
Implements ```HttpServerService```
See ["/src/examples/example2/Example2.java"](/src/examples/example2/)
## for HTTP Client
Use "java.net.http.HttpClient" on Java11+ or other library.