-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use HTTP bindings correctly (#579)
- Loading branch information
1 parent
20d7a67
commit 5f5040f
Showing
20 changed files
with
759 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# HTTP Test Project | ||
|
||
## Overview | ||
This project is a test suite for evaluating the HTTP server functionality in the Glee framework. It sets up an HTTP server on port 3000, and upon receiving a POST request, it sends multiple test requests to `https://httpbin.org/` to verify the operational aspects of the server. | ||
|
||
|
||
### Installation | ||
1. Navigate to the project directory: | ||
```sh | ||
cd examples/http-test | ||
``` | ||
3. Install the necessary Node.js packages: | ||
```sh | ||
npm install | ||
``` | ||
|
||
### Running the Server | ||
1. Start the HTTP server by running: | ||
```sh | ||
npm run dev | ||
``` | ||
2. The server will start on `http://localhost:3000`. | ||
|
||
### Testing the Server | ||
Send a POST request to `http://localhost:3000` using a tool like cURL or Postman. The server, upon receiving the request, will initiate several test requests to `https://httpbin.org/` and validate the functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
asyncapi: 3.0.0 | ||
info: | ||
title: Test HTTP in glee using httpbin.org | ||
version: 1.0.0 | ||
description: This app is a test app. it will send requests to httpbin.org to see if glee works well with http protocol. | ||
servers: | ||
httpbin.org: | ||
host: 'httpbin.org' | ||
protocol: https | ||
local-trigger: | ||
host: 'localhost:3000' | ||
protocol: http | ||
channels: | ||
TRIGGER: | ||
address: / | ||
servers: | ||
- $ref: '#/servers/local-trigger' | ||
messages: | ||
string: | ||
$ref: "#/components/messages/string" | ||
empty: | ||
$ref: "#/components/messages/empty" | ||
DELETE: | ||
address: /delete | ||
servers: | ||
- $ref: '#/servers/httpbin.org' | ||
GET: | ||
address: /get | ||
servers: | ||
- $ref: '#/servers/httpbin.org' | ||
POST: | ||
address: /post | ||
servers: | ||
- $ref: '#/servers/httpbin.org' | ||
PATCH: | ||
address: /patch | ||
servers: | ||
- $ref: '#/servers/httpbin.org' | ||
PUT: | ||
address: /put | ||
servers: | ||
- $ref: '#/servers/httpbin.org' | ||
operations: | ||
sendTrigger: | ||
action: send | ||
channel: | ||
$ref: "#/channels/TRIGGER" | ||
messages: | ||
- $ref: "#/components/messages/string" | ||
receiveTrigger: | ||
reply: | ||
channel: | ||
$ref: "#/channels/TRIGGER" | ||
messages: | ||
- $ref: "#/components/messages/string" | ||
channel: | ||
$ref: '#/channels/TRIGGER' | ||
action: receive | ||
bindings: | ||
http: | ||
method: POST | ||
sendDELETE: | ||
channel: | ||
$ref: '#/channels/DELETE' | ||
action: send | ||
bindings: | ||
http: | ||
method: DELETE | ||
receiveDELETE: | ||
channel: | ||
$ref: '#/channels/DELETE' | ||
action: receive | ||
sendGET: | ||
channel: | ||
$ref: '#/channels/GET' | ||
action: send | ||
bindings: | ||
http: | ||
method: GET | ||
receiveGET: | ||
channel: | ||
$ref: '#/channels/GET' | ||
action: receive | ||
bindings: | ||
http: | ||
method: GET | ||
sendPOST: | ||
channel: | ||
$ref: '#/channels/POST' | ||
action: send | ||
bindings: | ||
http: | ||
method: POST | ||
receivePOST: | ||
channel: | ||
$ref: '#/channels/POST' | ||
action: receive | ||
sendPATCH: | ||
channel: | ||
$ref: '#/channels/PATCH' | ||
action: send | ||
bindings: | ||
http: | ||
method: PATCH | ||
receivePATCH: | ||
channel: | ||
$ref: '#/channels/PATCH' | ||
action: receive | ||
sendPUT: | ||
channel: | ||
$ref: '#/channels/PUT' | ||
action: send | ||
bindings: | ||
http: | ||
method: PUT | ||
receivePUT: | ||
channel: | ||
$ref: '#/channels/PUT' | ||
action: receive | ||
components: | ||
messages: | ||
string: | ||
bindings: | ||
http: | ||
headers: | ||
type: object | ||
required: ["a", "b"] | ||
properties: | ||
a: | ||
type: string | ||
b: | ||
type: string | ||
payload: | ||
type: string | ||
empty: | ||
payload: | ||
type: "null" | ||
x-remoteServers: | ||
- httpbin.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Test HTTP in glee using httpbin.org 1.0.0 documentation | ||
|
||
This app is a test app. it will send requests to httpbin.org to see if glee works well with http protocol. | ||
|
||
## Table of Contents | ||
|
||
* [Servers](#servers) | ||
* [httpbin.org](#httpbinorg-server) | ||
* [local-trigger](#local-trigger-server) | ||
|
||
## Servers | ||
|
||
### `httpbin.org` Server | ||
|
||
* URL: `https://httpbin.org/` | ||
* Protocol: `https` | ||
|
||
|
||
|
||
### `local-trigger` Server | ||
|
||
* URL: `http://localhost:3000/` | ||
* Protocol: `http` | ||
|
||
|
||
|
||
## Operations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default async function ({ payload }) { | ||
if (!payload.url) { | ||
console.error("DELETE receive failed.") | ||
return | ||
} | ||
|
||
console.log("DELETE operation succeded..") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default async function ({ payload }) { | ||
if (!payload.url) { | ||
console.error("GET receive failed.") | ||
return | ||
} | ||
|
||
console.log("GET operation succeded..") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default async function ({ payload }) { | ||
if (!payload.url) { | ||
console.error("PATCH receive failed.") | ||
return | ||
} | ||
|
||
console.log("PATCH operation succeded..") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default async function ({ payload }) { | ||
if (!payload.url) { | ||
console.error("POST receive failed.") | ||
return | ||
} | ||
console.log("POST operation succeded..") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default async function ({ payload }) { | ||
if (!payload.url) { | ||
console.error("PUT receive failed.") | ||
return | ||
} | ||
|
||
console.log("PUT operation succeded..") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default async function (event) { | ||
const server = 'httpbin.org' | ||
return { | ||
reply: [{ | ||
payload: "You have successfully triggered the test server..." | ||
}], | ||
send: [ | ||
{ | ||
server, | ||
channel: "DELETE" | ||
}, | ||
{ | ||
server, | ||
channel: "GET" | ||
}, | ||
{ | ||
server, | ||
channel: "POST" | ||
}, | ||
{ | ||
server, | ||
channel: "PATCH" | ||
}, | ||
{ | ||
server, | ||
channel: "PUT" | ||
} | ||
], | ||
} | ||
} |
Oops, something went wrong.