/** * Calculate checksum for file given by {@code path} relative to server's {@code baseDir}. * * @param path file path relative to root defined by server's ```baseDir``` * @return calculated checksum * @throws Exception NoSuchFileException */ @Nullable String checksum(String path) throws Exception; }
/** * 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);
/** * The address of the interface that the application should bind to. * <p> * A value of null causes all interfaces to be bound. Defaults to null. * * @return The address of the interface that the application should bind to. */ @Nullable InetAddress getAddress();
/** * Sends the response back to the client, with no body. */ @NonBlocking void send();
/** * Deserializes the request body of the context into an object. * * @param context The context to deserialize * @param requestBody The request body to deserialize * @param parse The description of how to parse the request body * @param <T> the type of object to construct from the request body * @return The object representation of the request body, or {@code null} if this parser cannot parse to the requested type * @throws Exception if an error occurs parsing the request */ @Nullable <T> T parse(Context context, TypedData requestBody, Parse<T, O> parse) throws Exception;
/** * 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);
/** * Returns the header value with the specified header name. * <p> * If there is more than one header value for the specified header name, the first value is returned. * * @param name The case insensitive name of the header to get retrieve the first value of * @return the header value or {@code null} if there is no such header */ @Nullable String get(CharSequence name);
/** * 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);
/** * Returns the header value with the specified header name. * <p> * If there is more than one header value for the specified header name, the first value is returned. * * @param name The case insensitive name of the header to get retrieve the first value of * @return the header value or {@code null} if there is no such header */ @Nullable String get(String name);
/** * 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();
/** * The actual host/ip that the application is bound to. * * @return the actual host/ip that the application is bound to, or null if this server is not running */ @Nullable String getBindHost();
/** * 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);
/** * The type without parameters. * <p> * Given a mime type of "text/plain;charset=utf-8", returns "text/plain". * <p> * May be null to represent no content type. * * @return The mime type without parameters, or null if this represents the absence of a value. */ @Nullable String getType();
/** * The exception representing an unhealthy check, may be {@code null}. * <p> * Healthy results will never have an associated error. * * @return the exception representing an unhealthy check, may be {@code null} */ @Nullable public Throwable getError() { return error; }
/** * The error, if this event represents an error. * <p> * If {@link #isError()} returns {@code true}, this method will return the corresponding exception. * If {@link #isError()} returns {@code false}, this method will return null. * * @return the error if this event represents an error, else {@code null} */ @Nullable Throwable getThrowable();
/** * The data, if this event represents an emission of data. * <p> * If {@link #isData()} returns {@code true}, this method will return the corresponding data item. * If {@link #isData()} returns {@code false}, this method will return null. * * @return the data if this event represents data, else {@code null} */ @Nullable T getItem();
@Nullable @Override public Throwable getThrowable() { return null; }
@Nullable @Override public T getItem() { return null; }