Package io.github.sigmacasino
Class HTTPRoute
java.lang.Object
io.github.sigmacasino.HTTPRoute
- All Implemented Interfaces:
spark.Route
HTTPRoute is an abstract class that represents a route in the HTTP server.
It is a wrapper around the Spark Route interface, and is used to provide a
common fields for all routes in the server.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhandle
(spark.Request request, spark.Response response) Handles the request and returns the response.abstract void
Registers the route with Spark.
-
Field Details
-
app
The App object that the route is associated with. -
path
The path of the route, e.g. "/account/reset_password". This is the path that the route will be registered to with Spark. -
loginRequired
protected boolean loginRequiredWhether the route requires the user to be logged in.
-
-
Constructor Details
-
HTTPRoute
Constructor for the HTTPRoute class.- Parameters:
app
- The App object that the route is associated with.path
- The path of the route.
-
-
Method Details
-
handle
Handles the request and returns the response. This method is called by Spark when a request is made to the route. It should be overridden by subclasses to provide the route's functionality. Additionally, this super-implementation handles redirecting the user to the login page if the route requires the user to be logged in and returns boolean which says whether the redirect should occur.- Specified by:
handle
in interfacespark.Route
- Parameters:
request
- The request object.response
- The response object.- Returns:
- The response object, which might be text, HTTP code, etc.
- Throws:
Exception
- If an error occurs while handling the request.- See Also:
-
Route.handle(Request, Response)
-
registerSparkRoute
public abstract void registerSparkRoute()Registers the route with Spark.
-