yql_functions_servlet.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "yql_functions_servlet.h"
  2. #include <yt/yql/providers/yt/provider/yql_yt_provider.h>
  3. #include <yql/essentials/providers/config/yql_config_provider.h>
  4. #include <yql/essentials/providers/result/provider/yql_result_provider.h>
  5. #include <yql/essentials/core/type_ann/type_ann_core.h>
  6. namespace {
  7. void OutputKnownFunctions(TStringStream& out)
  8. {
  9. using namespace NYql;
  10. out <<
  11. "window.yql = {};\n"
  12. "window.yql.builtinFunctions = [";
  13. const auto& builtinFuncs = GetBuiltinFunctions();
  14. for (const auto& func: builtinFuncs) {
  15. out << '"' << func << "\",";
  16. }
  17. out << "];\n";
  18. out << "window.yql.supportedFunctions = [";
  19. const THashSet<TStringBuf>* functionsSet[] = {
  20. &YtDataSourceFunctions(),
  21. &YtDataSinkFunctions(),
  22. &ResultProviderFunctions(),
  23. &ConfigProviderFunctions()
  24. };
  25. for (const auto& funcs: functionsSet) {
  26. for (const auto& func: *funcs) {
  27. out << '"' << func << "\",";
  28. }
  29. }
  30. out << "];";
  31. }
  32. } // namspace
  33. namespace NYql {
  34. namespace NHttp {
  35. void TYqlFunctoinsServlet::DoGet(const TRequest& req, TResponse& resp) const
  36. {
  37. Y_UNUSED(req);
  38. TStringStream out;
  39. OutputKnownFunctions(out);
  40. resp.Body = TBlob::FromString(out.Str());
  41. resp.Headers.AddHeader(THttpInputHeader("Content-Type: text/javascript"));
  42. }
  43. } // namspace NNttp
  44. } // namspace NYql