Class Horses

All Implemented Interfaces:
spark.Route

public class Horses extends HTMLTemplateRoute
Handles the "/games/horses" route, fetching horse race data based on a replay ID and populating the HTML template with the race details or an error flag.
  • Constructor Details

    • Horses

      public Horses(App app)
      Initializes the route handler with the app instance and sets the route path.
      Parameters:
      app - The main application instance.
  • Method Details

    • getHTMLTemplatePath

      public String getHTMLTemplatePath(spark.Request request)
      Returns the path to the HTML template for the horse racing page.
      Specified by:
      getHTMLTemplatePath in class HTMLTemplateRoute
      Parameters:
      request - The HTTP request.
      Returns:
      The template path.
    • populateContext

      public Map<String,Object> populateContext(spark.Request request, spark.Response response) throws SQLException
      Populates the template context with race data (date, bet amount, user's guess, horse times, and Bezier curves) or redirects the user on error with a correct flag in the URL.
      Overrides:
      populateContext in class HTMLTemplateRoute
      Parameters:
      request - The HTTP request containing the query parameter.
      response - The HTTP response used to redirect the user.
      Returns:
      A map with race data or an error flag.
      Throws:
      SQLException - if a database access error occurs in any subclass implementation
    • getNotificationDefinitions

      public Map<String,String> getNotificationDefinitions()
      Description copied from class: HTMLTemplateRoute
      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.
      Overrides:
      getNotificationDefinitions in class HTMLTemplateRoute
      Returns:
      the definitions as an URL name-notification message map.