|
2 weeks ago | |
---|---|---|
src | 2 weeks ago | |
.gitignore | 2 years ago | |
README.md | 2 weeks ago | |
pom.xml | 2 weeks ago |
A collection of tools for easily starting a Jetty server embedded within your application.
Include the library in your project by adding the following dependency to your pom.xml
<dependency>
<groupId>com.mclarkdev.tools</groupId>
<artifactId>libwebsvc</artifactId>
<version>1.5.1</version>
</dependency>
Individual API handlers may be created by implementing LibWebSvcAPI.
The implemented class can then be passed to the server at creation time.
LibWebSvc webServer = new LibWebSvc(bindAddr, bindPort);
webServer.addHandler("/command", MyRestHandler.class);
webServer.start();
Individual Websocket handlers may be created by implemeting LibWebSvcWS.
The implemented class can then be passed to the server at creation time.
LibWebSvc webServer = new LibWebSvc(bindAddr, bindPort);
webServer.addWSHandler("/socket", MyWebsocketHandler.class);
webServer.start();
Static resources my be served by providing a resources directory containing the web app.
LibWebSvc webServer = new LibWebSvc(bindAddr, bindPort);
webServer.addResources(86400);
webServer.start();
Auth lists may be defined in the auth
directory relative to the project root. Each list shall be named {realm}.conf
where the realm can be user configurable for different access control groups.
Entries for authlists may be generated by appending each user to a newline, as a {user}:{sha256}
string, where the user password is SHA-256 encoded.
A helper method has been included to generate these entires. It may be invoked with the following command:
java -cp myapp.jar com.mclarkdev.tools.libwebsvc.LibWebSvcAuthGenerator {user} {pass}
Open source & free for all. ❤