Config - Pipelines
Configurations for pipelines happen within the Gateway Configuration - using the Ceptor console, you can add or remove pipelines. Direct configuration using JSON is described later on this page.
If you press "Add", you will be prompted for a name of the new pipeline to add - be sure to type in a unique name.
Once you have created a pipeline, it looks similar to this:
The pipeline view is split into 3 sections (you can resize by dragging the divider).
The top left is called Tasks, and contains a tree-structure view of all the tasks within your pipeline. You can drag tasks around to reorder them or move them to branches. To remove a task, right click it and select "Remove Task" from the popup menu.
The bottom left section contains configuration information for the currently selected task - here, you fill out any information needed for the individual task.
All tasks have a description, and it is often helpful to fill it out, since it will also be shown in the task tree.
You can drag new tasks in from the Task Palette, and drop them on existing tasks or branches.¨
All tasks are placed as JSON objects inside the "tasks" attribute within the pipeline (see example below this section).
Each task has an attribute called "class", and one called "description" - the class refers to the Java class within Ceptor Gateway which implements the task logic, and the description is for information purposes only.
In addition, each task has its own set of configuration attributes that are unique to this particular task.
Please refer to the descriptions on the individual pages for each task.
- Tasks - Branches
- Tasks - Transformations
- Tasks - Attributes
- Tasks - Connectivity
- Tasks - Validations
- Tasks - Actions
- Tasks - Logging
JSON Configuration for Pipelines
Below, is an example pipeline configuration for the Ceptor Gateway.
Pipelines are stored in the JSON Array "pipelines", as one JSON Object per pipeline.
Each pipeline has a name, and an array of tasks.
"pipelines": [ { "name": "validate_content", "tasks": [ { "else": [{ "input": "Content was not JSON", "description": "Trace that it was not JSON", "class": "io.ceptor.pipeline.tasks.TraceTask" }], "conditions.type": "and", "description": "If JSON input, validate it", "then": [ { "input": "Body: %{REQUEST_BODY}", "description": "Trace content", "class": "io.ceptor.pipeline.tasks.TraceTask" }, { "max.key.length": 50, "input": "%{REQUEST_BODY}", "max.array.items": 1000, "description": "Validate JSON structure is correct", "max.depth": 50, "response.reason": "Invalid JSON", "require.object": false, "max.string.value.length": 200, "response.status": 400, "class": "io.ceptor.pipeline.tasks.ValidateJSONTask", "max.objects.items": 100 } ], "conditions": [{ "deny": false, "values": ["application/json*"], "name": "content-type", "type": "header" }], "class": "io.ceptor.pipeline.tasks.IfThenElseTask" }, { "input": "Validation of JSON done.", "description": "that we are done", "class": "io.ceptor.pipeline.tasks.TraceTask" } ] }, { "name": "get country info", "tasks": [ { "completed.name": "lang_da", "request.headers": [{ "name": "Accept", "value": "application/json" }], "method": "GET", "destination": "restcountries.eu", "description": "Get information for countries speaking danish", "class": "io.ceptor.pipeline.tasks.RetrieveURLTask", "uri": "https://restcountries.eu/rest/v2/lang/da" }, { "input": "%{compreq.response.headers:lang_da}", "target.attribute.name": "savedheaders", "description": "Move response headers to request attribute test", "class": "io.ceptor.pipeline.tasks.SetRequestAttributeTask" }, { "input": "%{compreq.response:lang_da}", "description": "Extract a few attributes from the response", "class": "io.ceptor.pipeline.tasks.ScriptRunnerTask", "script": "//var json = JSON.parse(new java.lang.String(state.completedRequests.get(\"lang_da\").response));\n\n// Input is set to the response contents\nvar json = JSON.parse(input);\n\njson = json[0];\n\nvar result = {\n \"name\": json.name,\n \"tld\": json.topLevelDomain[0],\n \"capital\": json.capital,\n \"headers\": JSON.parse(state.requestAttributes.get(\"savedheaders\"))\n}\n\nstate.requestAttributes.put(\"result\", JSON.stringify(result));" }, { "input": "%{requestattribute:result}", "target.attribute.name": "xmloutput", "root.attribute.name": "result", "description": "Transform output json to xml", "class": "io.ceptor.pipeline.tasks.TransformJsonToXmlTask" }, { "else": [ { "description": "Move XML into JSON response", "class": "io.ceptor.pipeline.tasks.ScriptRunnerTask", "script": "var xml = context.requestAttributes.get(\"xmloutput\");\nvar json = JSON.parse(context.requestAttributes.get(\"result\"));\n\n//print(xml);\n//print(json);\n\n// Just to demonstrate, change the response slightly and move XML into an attribute within it\njson.xml = xml;\n\n// Update result\ncontext.requestAttributes.put(\"result\", JSON.stringify(json));" }, { "response.contenttype": "application/json", "description": "Write result created by script in previous taks", "response.reason": "Language Data", "response.status": 200, "response.content": "%{requestattribute:result}", "class": "io.ceptor.pipeline.tasks.SendResponseTask" } ], "description": "if transformation failed", "then": [{ "response.contenttype": "text/plain", "description": "send failure", "response.reason": "Epic failure", "response.status": 400, "response.content": "%{EXCEPTION_LOG}", "class": "io.ceptor.pipeline.tasks.SendResponseTask" }], "class": "io.ceptor.pipeline.tasks.IfFailureTask" } ] } ]
© Ceptor ApS. All Rights Reserved.