org.nustaq.kontraktor.webapp.transpiler.TranspilerHook Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kontraktor-http Show documentation
Show all versions of kontraktor-http Show documentation
http connectivity for kontraktor
package org.nustaq.kontraktor.webapp.transpiler;
import org.nustaq.kontraktor.webapp.javascript.FileResolver;
import java.io.File;
import java.util.List;
import java.util.Map;
/**
* Created by ruedi on 21.05.16.
*
* hook to transpile files dynamically. Hooks can be registered in the http4k builder class 'BldResPath'
*/
public interface TranspilerHook {
/**
* indicates a file is being accessed. in dev mode this is called always (so its up to the implementation
* to check for filedate/modification).
*
* In order to run an external transpiler, just run transpilation synchronous such that the given file is
* updated and return null.
*
* Alternatively an implementation might choose to just transpile dynamically and directly return byte[].
*
* NOTE: transpilation is static. this means in production mode it will be called once on first resource access.
*
* @param f - the file being accessed (after resourcepath resolvment)
* @return either (transpiled) file content or null.
* Should throw an exception in case an error occured during transpile.
*/
byte[] transpile(File f) throws TranspileException;
default byte[] transpile(File f, FileResolver resolver, Map alreadyResolved) {
return transpile(f);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy