Class ApiModule
java.lang.Object
com.haven.havenplugin.ApiModule
- All Implemented Interfaces:
Module
HTTP server module. Owns the server socket and the route table.
Routes registered via registerRoute(String, int, ApiModule.RouteHandler) (and removed via
deregisterRoute(String)) are held in memory independently of the server
lifecycle. Stopping and restarting the module does not wipe registered
routes, so other modules can register their routes at enable-time once
without caring whether ApiModule is currently up.
Other modules should obtain this instance via
plugin.getModule(ApiModule.class) inside their own
onEnable / onDisable.
DO NOT run without a reverse proxy.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidderegisterRoute(String path) Remove all routes whose base path matchespath.Command names this module owns, matching entries in plugin.yml.List<org.bukkit.event.Listener> getName()voidvoidvoidregisterRoute(String path, int argCount, ApiModule.RouteHandler handler) Register a route.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Module
getExecutor, getTabCompleter, reloadConfig
-
Constructor Details
-
ApiModule
public ApiModule(int port)
-
-
Method Details
-
registerRoute
Register a route. Always available regardless of module enable state.- Parameters:
path- Base path, no leading slash (e.g."shop/buy")argCount- Number of URL segments expected after the base pathhandler- Handler invoked on a worker thread for every matching request
-
deregisterRoute
Remove all routes whose base path matchespath. Call this from a module'sonDisableto clean up its routes. -
onEnable
-
onDisable
-
getName
-
getListeners
- Specified by:
getListenersin interfaceModule
-
getCommands
Description copied from interface:ModuleCommand names this module owns, matching entries in plugin.yml.- Specified by:
getCommandsin interfaceModule
-