mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	add examples for HTTP in/response node
This commit is contained in:
		
							
								
								
									
										226
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,226 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "87bd706a.aec93", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Create an HTTP Endpoint", | ||||
|         "info": "The `HTTP In` and `HTTP Response` pair of nodes are the starting point for all HTTP endpoints you create.\n\nAny flow that starts with an `HTTP In` node must have a path to an `HTTP Response` node otherwise requests will eventually timeout.\n\nThe `HTTP Response` node uses the `payload` property of messages it receives as the body of the response. Other properties can be used to further customize the response - they are covered in other recipes.\n\nThe `Template` node provides a convenient way to embed a body of content into a flow. It may be desirable to maintain such static content outside of the flow.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/create-an-http-endpoint) for details.", | ||||
|         "x": 230, | ||||
|         "y": 100, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "7f10afe.b1faa5", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello", | ||||
|         "method": "get", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 240, | ||||
|         "y": 140, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "db134063.83b7a" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "d5ce67fc.e6e608", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 490, | ||||
|         "y": 140, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "5a89ce70.db6d5", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "GET", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "http://localhost:1880/hello", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 390, | ||||
|         "y": 280, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "18b48ed8.1072e1" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "31f7aabb.3fbe06", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "", | ||||
|         "payloadType": "date", | ||||
|         "x": 240, | ||||
|         "y": 280, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "5a89ce70.db6d5" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "18b48ed8.1072e1", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 550, | ||||
|         "y": 280, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "3c61c12c.5abaae", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Send HTTP request: http://localhost:1880/hello", | ||||
|         "info": "`http request` node can be used to make an **HTTP GET** request.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/simple-get-request) for details.", | ||||
|         "x": 300, | ||||
|         "y": 200, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "db134063.83b7a", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Hello World!</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 370, | ||||
|         "y": 140, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "d5ce67fc.e6e608" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "83e766b1.154438", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "GET", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 390, | ||||
|         "y": 360, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "188bc18.5487a3f" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "89c4d7a7.f8d798", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "url", | ||||
|                 "v": "http://localhost:1880/hello", | ||||
|                 "vt": "str" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "", | ||||
|         "payloadType": "date", | ||||
|         "x": 240, | ||||
|         "y": 360, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "83e766b1.154438" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "188bc18.5487a3f", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 550, | ||||
|         "y": 360, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "a65364a3.c72a58", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Set URL in HTTP request node setting panel", | ||||
|         "info": "`http request` node can be used to make an **HTTP GET** request.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/simple-get-request) for details.", | ||||
|         "x": 490, | ||||
|         "y": 240, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "47396a8e.6804f4", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Set URL via url property of input message of HTTP request node", | ||||
|         "info": "Target URL of `http request` node can be specified via `url` property of input message.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/set-request-url) for details.", | ||||
|         "x": 550, | ||||
|         "y": 320, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "ac0b58f6.c85138", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-query", | ||||
|         "method": "get", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 260, | ||||
|         "y": 560, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "d9c345c7.c2e148" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "c110b7f7.22f238", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 530, | ||||
|         "y": 560, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "976b2bb3.f5ff98", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Handle query parameters passed to an HTTP endpoint", | ||||
|         "info": "The `HTTP in` node can accept query parameters passwd to an HTTP endpoint.  It use the `msg.req.query` property of the message sent by the HTTP In node to access the parameters.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/handle-query-parameters) for details.", | ||||
|         "x": 320, | ||||
|         "y": 520, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "77a6b44f.4695ac", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "", | ||||
|         "payloadType": "date", | ||||
|         "x": 240, | ||||
|         "y": 660, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "9094aba0.095678" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "f523b8e.b5c8c48", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 550, | ||||
|         "y": 660, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "9a63c9c5.949128", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Send HTTP GET request: http://localhost:1880/hello-query?name=Nick", | ||||
|         "info": "`http request` node can be used to send **HTTP GET** request.", | ||||
|         "x": 370, | ||||
|         "y": 620, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "d9c345c7.c2e148", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Hello {{req.query.name}}!</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 410, | ||||
|         "y": 560, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "c110b7f7.22f238" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "9094aba0.095678", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "GET", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "http://localhost:1880/hello-query?name=Nick", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 390, | ||||
|         "y": 660, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "f523b8e.b5c8c48" | ||||
|             ] | ||||
|         ] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "9b2d7459.8dd598", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-param/:name", | ||||
|         "method": "get", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 290, | ||||
|         "y": 900, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "83753c80.5e271" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "7fe50f46.46209", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 590, | ||||
|         "y": 900, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "6e88d2b.828a92c", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Handle URL parameters in an HTTP endpoint", | ||||
|         "info": "Named path parameters (e.g. `:name`) in the URL property can be used to identify parts of the path that can vary between requests.\n\nThe `msg.req.params` property is an object of key/value pairs for each path parameter.", | ||||
|         "x": 290, | ||||
|         "y": 860, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "214bc398.b3482c", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "GET", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "http://localhost:1880/hello-param/Nick", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 390, | ||||
|         "y": 1000, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "70c0eba4.5f0dc4" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "70c0eba4.5f0dc4", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 550, | ||||
|         "y": 1000, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "83753c80.5e271", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Hello {{req.params.name}}!</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 470, | ||||
|         "y": 900, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "7fe50f46.46209" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "89523bfe.6e5c18", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "", | ||||
|         "payloadType": "date", | ||||
|         "x": 240, | ||||
|         "y": 1000, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "214bc398.b3482c" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "6276a6cd.5c3b18", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Send HTTP GET request: http://localhost:1880/hello-param/Nick", | ||||
|         "info": "`http request` node can be used to send **HTTP GET** request.", | ||||
|         "x": 350, | ||||
|         "y": 960, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										140
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "1ccc20e.71730df", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-headers", | ||||
|         "method": "get", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 270, | ||||
|         "y": 1260, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "3a62f641.2c0e8a" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "bc626348.1496d", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 550, | ||||
|         "y": 1260, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "b13b7c19.79cbd", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Access HTTP request headers", | ||||
|         "info": " `msg.req.headers` property of the message sent by the `HTTP In` node to access the headers.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/access-http-request-headers) for details.", | ||||
|         "x": 240, | ||||
|         "y": 1220, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "7fe0fee5.f3ed7", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "GET", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "http://localhost:1880/hello-headers", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 390, | ||||
|         "y": 1360, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "65b13d57.700074" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "65b13d57.700074", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 550, | ||||
|         "y": 1360, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "3a62f641.2c0e8a", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>User agent: {{req.headers.user-agent}}</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 430, | ||||
|         "y": 1260, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "bc626348.1496d" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "757fe655.e28558", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "headers", | ||||
|                 "v": "{\"User-Agent\":\"Node-RED\"}", | ||||
|                 "vt": "json" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "", | ||||
|         "payloadType": "date", | ||||
|         "x": 240, | ||||
|         "y": 1360, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "7fe0fee5.f3ed7" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "5195095.03b4cf8", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Set HTTP request header & send HTTP GET request: http://localhost:1880/hello-headers", | ||||
|         "info": "The field value pairs of the request headers \nyou would like to include in the message sent to the `HTTP request` node can be specified by setting `the msg.headers` field.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/set-request-header) for details.", | ||||
|         "x": 430, | ||||
|         "y": 1320, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "69a64e3d.84da3", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-raw", | ||||
|         "method": "post", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 260, | ||||
|         "y": 1560, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "38d357a7.b69d08" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "43e49c36.dc7624", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 530, | ||||
|         "y": 1560, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "8cb4b74e.602c28", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Post data to a flow", | ||||
|         "info": "The `HTTP In` node can listen for POST requests.  It returns the posted data as `msg.payload`.\n\nSee Node-RED cookbook items(\n[post raw data(https://cookbook.nodered.org/http/post-raw-data-to-a-flow), [post form data](https://cookbook.nodered.org/http/post-form-data-to-a-flow), [post JSON data](https://cookbook.nodered.org/http/post-json-data-to-a-flow)\n) for details.", | ||||
|         "x": 210, | ||||
|         "y": 1520, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "ec661b6b.c3c2b8", | ||||
|         "type": "http request", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "method": "POST", | ||||
|         "ret": "txt", | ||||
|         "paytoqs": "ignore", | ||||
|         "url": "http://localhost:1880/hello-raw", | ||||
|         "tls": "", | ||||
|         "persist": false, | ||||
|         "proxy": "", | ||||
|         "authType": "", | ||||
|         "x": 370, | ||||
|         "y": 1660, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "7c2812c.c6ee7ec" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "7c2812c.c6ee7ec", | ||||
|         "type": "debug", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "active": true, | ||||
|         "tosidebar": true, | ||||
|         "console": false, | ||||
|         "tostatus": false, | ||||
|         "complete": "false", | ||||
|         "statusVal": "", | ||||
|         "statusType": "auto", | ||||
|         "x": 530, | ||||
|         "y": 1660, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "38d357a7.b69d08", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Hello {{payload}}</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 410, | ||||
|         "y": 1560, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "43e49c36.dc7624" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "e45041b6.9ec13", | ||||
|         "type": "inject", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "props": [ | ||||
|             { | ||||
|                 "p": "payload" | ||||
|             }, | ||||
|             { | ||||
|                 "p": "topic", | ||||
|                 "vt": "str" | ||||
|             } | ||||
|         ], | ||||
|         "repeat": "", | ||||
|         "crontab": "", | ||||
|         "once": false, | ||||
|         "onceDelay": 0.1, | ||||
|         "topic": "", | ||||
|         "payload": "Nick", | ||||
|         "payloadType": "str", | ||||
|         "x": 230, | ||||
|         "y": 1660, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "ec661b6b.c3c2b8" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "af33dae7.b21138", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Send HTTP POST request: http://localhost:1880/hello-raw", | ||||
|         "info": "", | ||||
|         "x": 330, | ||||
|         "y": 1620, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										126
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										126
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,126 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "59760c9d.172d94", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-upload", | ||||
|         "method": "post", | ||||
|         "upload": true, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 270, | ||||
|         "y": 1980, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "e30073f3.ad429" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "d0b3e8b4.2cfde8", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Post file to a flow", | ||||
|         "info": "The `HTTP In` node can listen for POST requests for file upload.  Information for uploaded files can be accessed from `msg.req.files`.\n", | ||||
|         "x": 200, | ||||
|         "y": 1760, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "a888a043.ebb72", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-upload", | ||||
|         "method": "get", | ||||
|         "upload": false, | ||||
|         "swaggerDoc": "", | ||||
|         "x": 270, | ||||
|         "y": 1880, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "14b950b.0ed5aaf" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "2ccb67c7.02c568", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 590, | ||||
|         "y": 1880, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "14b950b.0ed5aaf", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <form method=\"POST\" enctype=\"multipart/form-data\">\n            <div>\n                <label for=\"file\">Select file to upload:</label>\n                <input type=\"file\" id=\"file\" name=\"file\"/>\n            </div>\n            <div>\n                <button type=\"submit\">OK</button>\n            </div>\n        </form>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 440, | ||||
|         "y": 1880, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "2ccb67c7.02c568" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "54f2edb5.62fca4", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "statusCode": "", | ||||
|         "headers": {}, | ||||
|         "x": 590, | ||||
|         "y": 1980, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "e30073f3.ad429", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Hello {{req.files.0.originalname}}</h1>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 440, | ||||
|         "y": 1980, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "54f2edb5.62fca4" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "6c3c1bf.48cc2e4", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Create HTTP page for file upload: open http://localhost:1880/hello-upload \\n from Web browser.  Then upload a file.", | ||||
|         "info": "", | ||||
|         "x": 440, | ||||
|         "y": 1820, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "c6242caa.8ec63", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Serve POST request for file upload", | ||||
|         "info": "", | ||||
|         "x": 320, | ||||
|         "y": 1940, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
							
								
								
									
										187
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,187 @@ | ||||
| [ | ||||
|     { | ||||
|         "id": "c362b989.954ae8", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-cookie", | ||||
|         "method": "get", | ||||
|         "swaggerDoc": "", | ||||
|         "x": 250, | ||||
|         "y": 2200, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "21ddf71f.d00518" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "21ddf71f.d00518", | ||||
|         "type": "function", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Format cookies", | ||||
|         "func": "msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;", | ||||
|         "outputs": 1, | ||||
|         "noerr": 0, | ||||
|         "x": 460, | ||||
|         "y": 2200, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "f3aa98c1.befc18" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "f3aa98c1.befc18", | ||||
|         "type": "template", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "page", | ||||
|         "field": "payload", | ||||
|         "fieldType": "msg", | ||||
|         "format": "html", | ||||
|         "syntax": "mustache", | ||||
|         "template": "<html>\n    <head></head>\n    <body>\n        <h1>Cookies</h1>\n        <a href=\"hello-cookie/add\">Add a cookie</a><br/>\n        <a href=\"hello-cookie/clear\">Clear cookies</a><br/>\n        <pre>{{ payload }}</pre>\n    </body>\n</html>", | ||||
|         "output": "str", | ||||
|         "x": 650, | ||||
|         "y": 2200, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "f52e2880.180968" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "f52e2880.180968", | ||||
|         "type": "http response", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "x": 870, | ||||
|         "y": 2200, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "9a2a9a4.0fc0768", | ||||
|         "type": "change", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Redirect to /hello-cookie", | ||||
|         "rules": [ | ||||
|             { | ||||
|                 "t": "set", | ||||
|                 "p": "statusCode", | ||||
|                 "pt": "msg", | ||||
|                 "to": "302", | ||||
|                 "tot": "num" | ||||
|             }, | ||||
|             { | ||||
|                 "t": "set", | ||||
|                 "p": "headers", | ||||
|                 "pt": "msg", | ||||
|                 "to": "{}", | ||||
|                 "tot": "json" | ||||
|             }, | ||||
|             { | ||||
|                 "t": "set", | ||||
|                 "p": "headers.location", | ||||
|                 "pt": "msg", | ||||
|                 "to": "/hello-cookie", | ||||
|                 "tot": "str" | ||||
|             } | ||||
|         ], | ||||
|         "action": "", | ||||
|         "property": "", | ||||
|         "from": "", | ||||
|         "to": "", | ||||
|         "reg": false, | ||||
|         "x": 670, | ||||
|         "y": 2260, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "f52e2880.180968" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "afefb90.53dcf48", | ||||
|         "type": "function", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Add a cookie", | ||||
|         "func": "msg.cookies = { };\nmsg.cookies[\"demo-\"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;", | ||||
|         "outputs": 1, | ||||
|         "noerr": 0, | ||||
|         "x": 450, | ||||
|         "y": 2240, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "9a2a9a4.0fc0768" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "d5205a2c.db9018", | ||||
|         "type": "function", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Clear cookies", | ||||
|         "func": "// Find demo cookies and clear them\nvar cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n    msg.cookies[cookieName] = null;\n});\n\nreturn msg;", | ||||
|         "outputs": 1, | ||||
|         "noerr": 0, | ||||
|         "x": 460, | ||||
|         "y": 2280, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "9a2a9a4.0fc0768" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "fda60c66.04975", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-cookie/add", | ||||
|         "method": "get", | ||||
|         "swaggerDoc": "", | ||||
|         "x": 260, | ||||
|         "y": 2240, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "afefb90.53dcf48" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "35285a76.1f8636", | ||||
|         "type": "http in", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "", | ||||
|         "url": "/hello-cookie/clear", | ||||
|         "method": "get", | ||||
|         "swaggerDoc": "", | ||||
|         "x": 260, | ||||
|         "y": 2280, | ||||
|         "wires": [ | ||||
|             [ | ||||
|                 "d5205a2c.db9018" | ||||
|             ] | ||||
|         ] | ||||
|     }, | ||||
|     { | ||||
|         "id": "cb094c2f.7e34d", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Working with cookies", | ||||
|         "info": "The messages sent by the `HTTP In` node include the `msg.req.cookies` property that lists the cookies set on the current request.\n\nThe `HTTP Response` node will use the `msg.cookies` property in order to set or clear cookies.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/work-with-cookies) for details.\n", | ||||
|         "x": 220, | ||||
|         "y": 2100, | ||||
|         "wires": [] | ||||
|     }, | ||||
|     { | ||||
|         "id": "287a9146.683afe", | ||||
|         "type": "comment", | ||||
|         "z": "d41b4dd3.ecd6a", | ||||
|         "name": "Create HTTP page for testing cookies: open http://localhost:1880/hello-cookie from Web browser. ", | ||||
|         "info": "", | ||||
|         "x": 500, | ||||
|         "y": 2160, | ||||
|         "wires": [] | ||||
|     } | ||||
| ] | ||||
		Reference in New Issue
	
	Block a user