// // Copyright 2020 SenX S.A.S. // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, version 3. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see // 15 m MSTU / MACROTTL { 'name' '@senx/discovery/dispatcher' 'desc' <' Dispatches incoming HTTP requests to macros which will produce dashboards. Create an HTTP Plugin endpoint specification with the following content: ``` { 'path' '/discovery/' 'prefix' true 'parsePayload' true 'macro' <% 'senx/discovery/dashboard/' @senx/discovery/dispatcher %> } ``` Any request to `/discovery/foo/bar` will run the macro `@senx/discovery/dashboard/foo/bar`. '> 'sig' [ [ [ 'prefix:STRING' 'request:MAP' ] [ 'html:STRING' ] ] ] 'params' { 'request' 'HTTP request `MAP` as produced by the [`HTTP Plugin`](https://www.warp10.io/content/03_Documentation/07_Extending_Warp_10/15_Native_Plugins/01_HTTP_Plugin).' 'prefix' 'Prefix to prepend to the `pathinfo` name in order to produce the macro to use.' 'html' 'HTML rendering of a Discovery dashboard.' } 'examples' [] } '.info' STORE <% !$.info INFO // // Save the HTTP request and the macro prefix // [ 'request' 'prefix' ] STORE $request 'params' GET 'params' STORE <% // // Extract the dashboard name and invoke macro @ with the parameters as input // $prefix $request 'pathinfo' GET + RUN %> <% // // Build a simple page for reporting the error // <'
SenX
An error occurred while attempting to dispatch your Discovery request.
{{stacktrace}}
'> { 'stacktrace' ERROR ->JSON } TEMPLATE %> <% %> TRY // // Store the resulting HTML // 'body' STORE { 'status' 200 'body' $body 'headers' { 'Content-Type' 'text/html' 'Access-Control-Allow-Origin' '*' } } %>