Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (33 sloc) 1.06 KB
using System.Linq;
using System.Threading.Tasks;
using ServiceStack;
using ServiceStack.Script;
namespace ScriptInfo
{
[Route("/script/eval")]
public class EvaluateScript
{
public string Script { get; set; }
}
[ReturnExceptionsInJson]
public class ScriptServices : Service
{
public ISharpPages Pages { get; set; }
public async Task<string> Any(EvaluateScript request)
{
var feature = HostContext.GetPlugin<SharpPagesFeature>();
var context = new ScriptContext {
ScriptMethods = {
new ScriptInfoMethods(),
feature.ScriptMethods.FirstOrDefault(x => x.GetType().Name == "ServerInfoFilters")
},
VirtualFiles = feature.VirtualFiles,
}.Init();
var pageResult = new PageResult(context.OneTimePage(request.Script))
{
Args = base.Request.GetRequestParams().ToObjectDictionary()
};
return await pageResult.RenderToStringAsync();
}
}
}
You can’t perform that action at this time.