Skip to content

Commit

Permalink
Changes after first round of review
Browse files Browse the repository at this point in the history
  • Loading branch information
perwendel committed Sep 2, 2015
1 parent a2dab91 commit a2be77f
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 154 deletions.
111 changes: 62 additions & 49 deletions src/main/java/spark/Routable.java
Expand Up @@ -20,10 +20,29 @@
import spark.utils.SparkUtils;

/**
* Routable interface. Lets implementing classes inherit default routable functionality.
* Routable abstract class. Lets extending classes inherit default routable functionality.
*/
abstract class Routable {

/**
* Adds a route
*
* @param httpMethod the HTTP method
* @param route the route implementation
*/
protected abstract void addRoute(String httpMethod, RouteImpl route);

/**
* Adds a filter
*
* @param httpMethod the HTTP method
* @param filter the route implementation
*/
protected abstract void addFilter(String httpMethod, FilterImpl filter);

/////////////////////////////
// Default implementations //

/**
* Map the route for HTTP GET requests
*
Expand Down Expand Up @@ -306,9 +325,9 @@ public void get(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void get(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.get.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -332,9 +351,9 @@ public void post(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void post(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.post.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -358,9 +377,9 @@ public void put(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void put(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.put.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -384,9 +403,9 @@ public void delete(String path, TemplateViewRoute route, TemplateEngine engine)
* @param engine the template engine
*/
public void delete(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.delete.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -410,9 +429,9 @@ public void patch(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void patch(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.patch.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -436,9 +455,9 @@ public void head(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void head(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.head.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -462,9 +481,9 @@ public void trace(String path, TemplateViewRoute route, TemplateEngine engine) {
* @param engine the template engine
*/
public void trace(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.trace.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -488,9 +507,9 @@ public void connect(String path, TemplateViewRoute route, TemplateEngine engine)
* @param engine the template engine
*/
public void connect(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.connect.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand All @@ -514,9 +533,9 @@ public void options(String path, TemplateViewRoute route, TemplateEngine engine)
* @param engine the template engine
*/
public void options(String path,
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
String acceptType,
TemplateViewRoute route,
TemplateEngine engine) {
addRoute(HttpMethod.options.name(), TemplateViewRouteImpl.create(path, acceptType, route, engine));
}

Expand Down Expand Up @@ -617,9 +636,9 @@ public void delete(String path, Route route, ResponseTransformer transformer) {
* @param transformer the response transformer
*/
public void delete(String path,
String acceptType,
Route route,
ResponseTransformer transformer) {
String acceptType,
Route route,
ResponseTransformer transformer) {
addRoute(HttpMethod.delete.name(), ResponseTransformerRouteImpl.create(path, acceptType, route, transformer));
}

Expand Down Expand Up @@ -666,9 +685,9 @@ public void connect(String path, Route route, ResponseTransformer transformer) {
* @param transformer the response transformer
*/
public void connect(String path,
String acceptType,
Route route,
ResponseTransformer transformer) {
String acceptType,
Route route,
ResponseTransformer transformer) {
addRoute(HttpMethod.connect.name(), ResponseTransformerRouteImpl.create(path, acceptType, route, transformer));
}

Expand All @@ -692,9 +711,9 @@ public void trace(String path, Route route, ResponseTransformer transformer) {
* @param transformer the response transformer
*/
public void trace(String path,
String acceptType,
Route route,
ResponseTransformer transformer) {
String acceptType,
Route route,
ResponseTransformer transformer) {
addRoute(HttpMethod.trace.name(), ResponseTransformerRouteImpl.create(path, acceptType, route, transformer));
}

Expand All @@ -718,9 +737,9 @@ public void options(String path, Route route, ResponseTransformer transformer) {
* @param transformer the response transformer
*/
public void options(String path,
String acceptType,
Route route,
ResponseTransformer transformer) {
String acceptType,
Route route,
ResponseTransformer transformer) {
addRoute(HttpMethod.options.name(), ResponseTransformerRouteImpl.create(path, acceptType, route, transformer));
}

Expand All @@ -744,16 +763,10 @@ public void patch(String path, Route route, ResponseTransformer transformer) {
* @param transformer the response transformer
*/
public void patch(String path,
String acceptType,
Route route,
ResponseTransformer transformer) {
String acceptType,
Route route,
ResponseTransformer transformer) {
addRoute(HttpMethod.patch.name(), ResponseTransformerRouteImpl.create(path, acceptType, route, transformer));
}

// TO BE IMPLEMENTED

protected abstract void addRoute(String httpMethod, RouteImpl route);

protected abstract void addFilter(String httpMethod, FilterImpl filter);

}

0 comments on commit a2be77f

Please sign in to comment.