diff --git a/cmd/http/views/index.hbs b/cmd/http/views/index.hbs index e92bebf..cc3f9bb 100644 --- a/cmd/http/views/index.hbs +++ b/cmd/http/views/index.hbs @@ -63,6 +63,26 @@ color: #cccccc; font-weight: bold; } + + pre { + background-color: #282c34; + color: #abb2bf; + padding: 10px; + border-radius: 5px; + overflow-x: auto; + } + + .keyword { + color: #c678dd; + } + + .string { + color: #98c379; + } + + .number { + color: #61aeee; + } @@ -94,78 +114,79 @@

Examples

Go

-            
-                package main
+        
+            package main
 
-                import (
-                    "bytes"
-                    "encoding/json"
-                    "net/http"
-                )
+            import (
+                "bytes"
+                "encoding/json"
+                "net/http"
+            )
 
-                type Order struct {
-                    OrderID     string  `json:"order_id"`
-                    ClientID    string  `json:"client_id"`
-                    Amount      float64 `json:"amount"`
-                    Currency    string  `json:"currency"`
-                    ClientEmail string  `json:"client_email"`
+            type Order struct {
+                OrderID     string  `json:"order_id"`
+                ClientID    string  `json:"client_id"`
+                Amount      float64 `json:"amount"`
+                Currency    string  `json:"currency"`
+                ClientEmail string  `json:"client_email"`
+            }
+
+            func main() {
+                order := &Order{
+                    OrderID:     "123",
+                    ClientID:    "456",
+                    Amount:      100.0,
+                    Currency:    "USD",
+                    ClientEmail: "client@example.com",
                 }
 
-                func main() {
-                    order := &Order{
-                        OrderID:     "123",
-                        ClientID:    "456",
-                        Amount:      100.0,
-                        Currency:    "USD",
-                        ClientEmail: "client@example.com",
-                    }
-
-                    jsonValue, _ := json.Marshal(order)
-                    _, err := http.Post("{{host}}/order", "application/json", bytes.NewBuffer(jsonValue))
-                    if err != nil {
-                        // handle error
-                    }
+                jsonValue, _ := json.Marshal(order)
+                _, err := http.Post("{{host}}/order", "application/json", bytes.NewBuffer(jsonValue))
+                if err != nil {
+                    // handle error
                 }
-            
-        
+ } + + +

Node.js

-            
-                const axios = require('axios');
+        
+            const axios = require('axios');
 
-                const order = {
-                    order_id: '123',
-                    client_id: '456',
-                    amount: 100.0,
-                    currency: 'USD',
-                    client_email: 'client@example.com'
-                };
+            const order = {
+                order_id: '123',
+                client_id: '456',
+                amount: 100.0,
+                currency: 'USD',
+                client_email: 'client@example.com'
+            };
 
-                axios.post('{{host}}/order', order)
-                    .then(response => {
-                        console.log(response.data);
-                    })
-                    .catch(error => {
-                        console.error(error);
-                    });
-            
-        
+ axios.post('{{host}}/order', order) + .then(response => { + console.log(response.data); + }) + .catch(error => { + console.error(error); + }); + +

CURL

-            
-                curl -X POST {{host}}/order \
-                -H 'Content-Type: application/json' \
-                -d '{
-                    "order_id": "123",
-                    "client_id": "456",
-                    "amount": 100.0,
-                    "currency": "USD",
-                    "client_email": "client@example.com"
-                }'
-            
-        
+ + curl -X POST {{host}}/order \ + -H 'Content-Type: application/json' \ + -d '{ + "order_id": "123", + "client_id": "456", + "amount": 100.0, + "currency": "USD", + "client_email": "client@example.com" + }' + +

Handling the Response

The response from the /order endpoint is an HTML page that should be displayed to the user. This can be done