Skip to content

A java library for bootstrapping a web application with java backend, and ldf+mustache frontend

License

Notifications You must be signed in to change notification settings

AUTplayed/ldfSpark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ldfSpark

A java library for bootstrapping a web application with java backend, and ldf+mustache frontend

maven

<dependency>
  <groupId>codes.fepi</groupId>
  <artifactId>ldfSpark</artifactId>
  <version>1.1</version>
</dependency>

gradle

implementation 'codes.fepi:ldfSpark:1.1'

To get started look at the example in the test dir

This library is supposed to greatly simplify creating a new application with my ldf framework

The user only has to implement a Handler Class for handling the page content (annotated with @PageHandler):

@PageHandler
public class Handler {

	public Object index() {
		return "page content";
	}

	public Object otherPage(Request req) {
		return "other page content";
	}
	
	public Object login(Request req, Response res) {
		return "login page content";
	}
}

The method names correspond to the page names, if a method for a page doesn't exist, the page will 404. The page names also correspond to the template names.

For example:

  • Template file called login.html in template folder
  • Method in PageHandler public static Object login()

If you include ldf in the index.html in the public folder like this and disable hashurls then calling host/login will result in login.html being responded with the content of the login() method.

In the resources directory you will have to have 2 folders,

  • one for static resources (default "public")
  • one for the mustache-flavored template pages (default "templates")

To start the server/logic you have to call

LdfSpark.start();

or

LdfSpark.start("templateFolder");

or

LdfSpark.start("templateFolder", "publicFolder");

also you have to configure your spark config beforehand (like the port used) like this:

spark.Spark.port(8080);
LdfSpark.start();

About

A java library for bootstrapping a web application with java backend, and ldf+mustache frontend

Resources

License

Stars

Watchers

Forks

Packages