/** * Inserts some handlers into the pipeline, then delegates to the first. * <p> * The request and response of this object should not be accessed after this method is called. * * @param handlers The handlers to insert. */ @NonBlocking void insert(Handler... handlers);
/** * Sends the response back to the client, with no body. */ @NonBlocking void send();
/** * Sends the response, using the given content type and byte array as the response body. * @param contentType The value of the {@code Content-Type} header * @param bytes The response body */ @NonBlocking void send(CharSequence contentType, byte[] bytes);
/** * Sends the response, using the given content type and bytes as the response body. * @param contentType The value of the {@code Content-Type} header * @param buffer The response body */ @NonBlocking void send(CharSequence contentType, ByteBuf buffer);
/** * Initiates the shutdown process for the running application. * <p> * This method <i>may</i> return before the application is fully shut down. */ @NonBlocking void stop();
/** * Forwards the error to the {@link ClientErrorHandler} in this service. * * The default configuration of Ratpack includes a {@link ClientErrorHandler} in all contexts. * A {@link NotInRegistryException} will only be thrown if a very custom service setup is being used. * * @param statusCode The 4xx range status code that indicates the error type * @throws NotInRegistryException if no {@link ClientErrorHandler} can be found in the service */ @NonBlocking void clientError(int statusCode) throws NotInRegistryException;
/** * Sends the response, using "{@code application/octet-stream}" as the content type (if a content type hasn't * already been set) and the given byte array as the response body. * * @param bytes The response body */ @NonBlocking void send(byte[] bytes);
/** * Server stop event. * Executed after the root handler stops accepting requests and before the server closes the channel and thread pool. * * @param event meta information about the stop event * @throws Exception any */ @NonBlocking default void onStop(StopEvent event) throws Exception { }
/** * Sends the response, using the file as the response body. * <p> * This method does not set the content length, content type or anything else. * It is generally preferable to use the {@link ratpack.handling.Context#render(Object)} method with a file/path object, * or an {@link ratpack.handling.Chain#files(Action)}. * * @param file the response body */ @NonBlocking void sendFile(Path file);
/** * Delegate handling to the next handler in line. * <p> * The request and response of this object should not be accessed after this method is called. */ @NonBlocking void next();
/** * Inserts some handlers into the pipeline to execute with the given registry, then delegates to the first. * <p> * The given registry is only applicable to the inserted handlers. * <p> * Almost always, the registry should be a super set of the current registry. * * @param handlers The handlers to insert * @param registry The registry for the inserted handlers */ @NonBlocking void insert(Registry registry, Handler... handlers);
/** * See {@link ratpack.service.Service#onStart(ratpack.service.StartEvent)}. * * @param event meta information about the startup event * @throws Exception any */ @NonBlocking default void onStart(StartEvent event) throws Exception { }
/** * Sends the response, using "{@code text/plain}" as the content type and the given string as the response body. * <p> * Equivalent to calling "{@code send\("text/plain", text)}. * * @param text The text to render as a plain text response. */ @NonBlocking void send(String text);
@Override @NonBlocking public void next() { delegate.next(); }
@Override @NonBlocking public void clientError(int statusCode) throws NotInRegistryException { delegate.clientError(statusCode); }
@Override @NonBlocking public void render(Object object) { delegate.render(object); }
@NonBlocking default void then() { then(Block.noop()); }
@Override @NonBlocking public void insert(Handler... handlers) { delegate.insert(handlers); }
@Override @NonBlocking public void insert(Registry registry, Handler... handlers) { delegate.insert(registry, handlers); }
@Override @NonBlocking public void error(Throwable throwable) throws NotInRegistryException { delegate.error(throwable); }