Search in sources :

Example 1 with CliOverHttpContext

use of act.cli.CliOverHttpContext in project actframework by actframework.

the class CliOverHttp method run.

@PostAction("cmd")
public Result run(String cmd, ActionContext context) throws IOException {
    CliHandler handler = handler(cmd);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    CliContext cliContext = new CliOverHttpContext(context, os);
    handler.handle(cliContext);
    cliContext.flush();
    String txt = new String(os.toByteArray(), "UTF-8");
    txt = txt.replace("^J", "\n");
    return text(txt);
}
Also used : CliOverHttpContext(act.cli.CliOverHttpContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CliHandler(act.handler.CliHandler) CliContext(act.cli.CliContext) PostAction(org.osgl.mvc.annotation.PostAction)

Aggregations

CliContext (act.cli.CliContext)1 CliOverHttpContext (act.cli.CliOverHttpContext)1 CliHandler (act.handler.CliHandler)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PostAction (org.osgl.mvc.annotation.PostAction)1