routes

Tiny routing library for Java

License

License

GroupId

GroupId

me.geso
ArtifactId

ArtifactId

routes
Last Version

Last Version

0.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

routes
Tiny routing library for Java
Project URL

Project URL

http://github.com/tokuhirom/routes
Source Code Management

Source Code Management

https://github.com/tokuhirom/routes/

Download routes

How to add to project

<!-- https://jarcasting.com/artifacts/me.geso/routes/ -->
<dependency>
    <groupId>me.geso</groupId>
    <artifactId>routes</artifactId>
    <version>0.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/me.geso/routes/
implementation 'me.geso:routes:0.6.0'
// https://jarcasting.com/artifacts/me.geso/routes/
implementation ("me.geso:routes:0.6.0")
'me.geso:routes:jar:0.6.0'
<dependency org="me.geso" name="routes" rev="0.6.0">
  <artifact name="routes" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.geso', module='routes', version='0.6.0')
)
libraryDependencies += "me.geso" % "routes" % "0.6.0"
[me.geso/routes "0.6.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Routes for Java

Build Status

This is a tiny routing library for Java.

Synopsis

Your WebAction.java

@FunctionalInterface
public interface WebAction {
	void call(ServletRequest req, ServletResponse res);
}

Your routing code.

	// Create routing rules.
	router = new WebRouter<WebAction>();
	router.get("/", RootController::index)
			.get("/sample-json", RootController::sampleJson);
			
	// Match
	RoutingResult rr = router.match("GET", "/sample-json");
	if (rr != null) {
		if (rr.methodAllowed()) {
			return res405();
		} else {
			WebAction dst = rr.getDestination();
			return dst.invoke();
		}
	} else {
		return res404();
	}

Path Patterns

/member/{memberId}

Will match %r{^/member/[a-zA-Z0-9._-]+$}.

/download/*

Will match %r{^/download/.*$}.

/blog/{articleId:[0-9]+}

Will match %r{^/blog/[0-9]+$}. You can specify regular expression as a path.

Dependencies

  • Java 8

Versions

Version
0.6.0
0.5.0
0.4.0
0.3.9