-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomScriptResource.java
More file actions
27 lines (24 loc) · 955 Bytes
/
CustomScriptResource.java
File metadata and controls
27 lines (24 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.cueup.hegemon.example;
import com.cueup.hegemon.LoadError;
import com.cueup.hegemon.LoadPath;
import com.cueup.hegemon.Script;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
/**
* The CustomScriptResource is an example of evaluating non-bundled code. This can be used to implement application
* consoles or test in-development code in a production environment.
*
* NOTE: This isn't secure, and could do VERY BAD THINGS if used improperly. Don't do this without understanding the
* attack vector you're opening. Even legitimate users can cause problems on accident.
*/
@Path("/customScript")
@Produces(MediaType.APPLICATION_JSON)
public class CustomScriptResource {
@POST
public Object post(String postBody) throws IOException, LoadError {
return new Script("customScript", "function run() { " + postBody + " }").run("run");
}
}