Package io.github.sigmacasino
Class HTMLTemplateRoute
java.lang.Object
io.github.sigmacasino.HTTPRoute
io.github.sigmacasino.GetRoute
io.github.sigmacasino.HTMLTemplateRoute
- All Implemented Interfaces:
spark.Route
- Direct Known Subclasses:
Account
,Docs
,ER
,Games
,Horses
,Interfaces
,Login
,Register
,Requirements
,ResetPassword
,RiskAnalysis
,Root
,Roulette
,Structure
,SystemArchitecture
,TechStack
,Tests
,UML
A GET route that renders a Jinjava HTML template.
- See Also:
-
Jinjava
-
Field Summary
FieldsModifier and TypeFieldDescriptionA map of notification definitions to be used in the Jinjava HTML template.Fields inherited from class io.github.sigmacasino.HTTPRoute
app, loginRequired, path
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
HTMLTemplateRoute
(App app, String path) Creates a new HTMLTemplateRoute. -
Method Summary
Modifier and TypeMethodDescriptionabstract String
getHTMLTemplatePath
(spark.Request request) Returns the path to the Jinjava HTML template.Returns a map of notification definitions to be used in the Jinjava HTML template.handleGet
(spark.Request request, spark.Response response) Renders a Jinjava HTML template.populateContext
(spark.Request request, spark.Response response) Returns additional context to populate the Jinjava HTML template with.Methods inherited from class io.github.sigmacasino.GetRoute
handle, registerSparkRoute
-
Field Details
-
notificationDefinitions
A map of notification definitions to be used in the Jinjava HTML template. The keys are the URL names of the notifications, and the values are the notification messages.
-
-
Constructor Details
-
HTMLTemplateRoute
Creates a new HTMLTemplateRoute.- Parameters:
app
- app instance, passed to the super contructorpath
- the path of the route, passed to the super contructor
-
-
Method Details
-
handleGet
Renders a Jinjava HTML template. It populates the context with the request session attributes and the result of thepopulateContext(Request, Response)
method. It also adds a notification and its type to the context if the request contains an "error" or "success" query parameter.- Specified by:
handleGet
in classGetRoute
- Parameters:
request
- the requestresponse
- the response- Returns:
- the rendered HTML template as a string
- Throws:
SQLException
- if a database access error occurs in any subclass implementation
-
getHTMLTemplatePath
Returns the path to the Jinjava HTML template. -
getNotificationDefinitions
Returns a map of notification definitions to be used in the Jinjava HTML template. Intended to be overridden by subclasses, providing their own definitions based on all redirects which point the user to the route with any error or success tags.- Returns:
- the definitions as an URL name-notification message map.
-
populateContext
public Map<String,Object> populateContext(spark.Request request, spark.Response response) throws SQLException Returns additional context to populate the Jinjava HTML template with. By default, it returns an empty map. Intended to be overriden by subclasses.- Parameters:
request
- the requestresponse
- the response- Returns:
- the context as a variable-value map
- Throws:
SQLException
- if a database access error occurs in any subclass implementation
-