Interface HttpServer

All Known Implementing Classes:
ServerInstance

public interface HttpServer
Interface for an HTTP server.

This interface defines the methods required to start and stop an HTTP server, as well as to retrieve the port on which the server is running.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the port on which the server is running.
    boolean
    Checks if the server is currently running.
    static HttpServer
    newInstance(int port)
    Creates a new instance of the HTTP server with the specified port and default backlog.
    boolean
    start(Router router)
    Starts the HTTP server with the specified router.
    boolean
    Stops the HTTP server.
  • Field Details

  • Method Details

    • start

      boolean start(Router router) throws InterruptedException
      Starts the HTTP server with the specified router.
      Parameters:
      router - The router to handle incoming requests.
      Returns:
      true if the server started successfully, false otherwise.
      Throws:
      InterruptedException - If an error occurs while starting the server.
    • stop

      boolean stop() throws InterruptedException
      Stops the HTTP server.
      Returns:
      true if the server stopped successfully, false otherwise.
      Throws:
      InterruptedException - If an error occurs while stopping the server.
    • getInstancePort

      int getInstancePort()
      Retrieves the port on which the server is running.
      Returns:
      The port number.
    • isRunning

      boolean isRunning()
      Checks if the server is currently running.
      Returns:
      true if the server is running, false otherwise.
    • newInstance

      static HttpServer newInstance(int port)
      Creates a new instance of the HTTP server with the specified port and default backlog.
      Parameters:
      port - The port on which the server will listen for incoming connections.
      Returns:
      A new instance of the HTTP server.