Search in sources :

Example 1 with BaseDirRequiredException

use of ratpack.file.BaseDirRequiredException in project ratpack by ratpack.

the class DefaultFileHandlerSpec method build.

public static Handler build(ServerConfig serverConfig, Action<? super FileHandlerSpec> config) throws Exception {
    if (!serverConfig.isHasBaseDir()) {
        throw new BaseDirRequiredException("no base dir set for application");
    }
    DefaultFileHandlerSpec spec = new DefaultFileHandlerSpec();
    config.execute(spec);
    Handler handler = new FileHandler(spec.indexFiles, !serverConfig.isDevelopment());
    if (spec.dir != null) {
        handler = Handlers.fileSystem(serverConfig, spec.dir, handler);
    }
    if (spec.path != null) {
        handler = Handlers.prefix(spec.path, handler);
    }
    return handler;
}
Also used : BaseDirRequiredException(ratpack.file.BaseDirRequiredException) Handler(ratpack.handling.Handler)

Aggregations

BaseDirRequiredException (ratpack.file.BaseDirRequiredException)1 Handler (ratpack.handling.Handler)1