No Description

Matt Clark eea39f0900 Release 1.5.1 2 weeks ago
src eea39f0900 Release 1.5.1 2 weeks ago
.gitignore ba6e83f8eb Initial commit of LibAPIs. 2 years ago
README.md eea39f0900 Release 1.5.1 2 weeks ago
pom.xml eea39f0900 Release 1.5.1 2 weeks ago

README.md

LibWebSvc

A collection of tools for easily starting a Jetty server embedded within your application.

Maven Dependency

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>

Example

API Handlers

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();

WebSocket Handlers

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

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

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}

License

Open source & free for all. ❤