use of io.javalin.core.event.HandlerMetaInfo in project javalin by tipsy.
the class Javalin method addHandler.
/**
* Adds a request handler for the specified handlerType and path to the instance.
* Requires an access manager to be set on the instance.
* This is the method that all the verb-methods (get/post/put/etc) call.
*
* @see AccessManager
* @see <a href="https://javalin.io/documentation#handlers">Handlers in docs</a>
*/
public Javalin addHandler(@NotNull HandlerType handlerType, @NotNull String path, @NotNull Handler handler, @NotNull RouteRole... roles) {
Set<RouteRole> roleSet = new HashSet<>(Arrays.asList(roles));
javalinServlet.addHandler(handlerType, path, handler, roleSet);
eventManager.fireHandlerAddedEvent(new HandlerMetaInfo(handlerType, Util.prefixContextPath(javalinServlet.getConfig().contextPath, path), handler, roleSet));
return this;
}
use of io.javalin.core.event.HandlerMetaInfo in project BlackOnion-Bot by Black0nion.
the class Paths method handle.
@Override
public Object handle(Context ctx, JSONObject body, Map<String, String> headers, @Nullable BlackSession session, DiscordUser user) throws Exception {
PathListener instance = PathListener.getInstance();
Map<HandlerType, List<String>> collected = instance.handlerMetaInfoList.stream().collect(Collectors.groupingBy(HandlerMetaInfo::getHttpMethod, mapping(HandlerMetaInfo::getPath, toList())));
return new JSONObject(collected).put("WS", new JSONArray(instance.wsHandlerMetaInfoList.stream().map(WsHandlerMetaInfo::getPath).toList()));
}
Aggregations