feat: style css

This commit is contained in:
Urko 2023-07-20 08:58:45 +02:00
parent 80ffe559ef
commit fb11a01fa7
1 changed files with 80 additions and 59 deletions

View File

@ -63,6 +63,26 @@
color: #cccccc; color: #cccccc;
font-weight: bold; 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;
}
</style> </style>
</head> </head>
@ -94,78 +114,79 @@
<h3>Examples</h3> <h3>Examples</h3>
<h4>Go</h4> <h4>Go</h4>
<pre> <pre>
<code> <code>
package main <span class="keyword">package</span> main
import ( <span class="keyword">import</span> (
"bytes" <span class="string">"bytes"</span>
"encoding/json" <span class="string">"encoding/json"</span>
"net/http" <span class="string">"net/http"</span>
) )
type Order struct { <span class="keyword">type</span> Order <span class="keyword">struct</span> {
OrderID string `json:"order_id"` OrderID <span class="keyword">string</span> <span class="string">`json:"order_id"`</span>
ClientID string `json:"client_id"` ClientID <span class="keyword">string</span> <span class="string">`json:"client_id"`</span>
Amount float64 `json:"amount"` Amount <span class="keyword">float64</span> <span class="string">`json:"amount"`</span>
Currency string `json:"currency"` Currency <span class="keyword">string</span> <span class="string">`json:"currency"`</span>
ClientEmail string `json:"client_email"` ClientEmail <span class="keyword">string</span> <span class="string">`json:"client_email"`</span>
}
<span class="keyword">func</span> main() {
order := &Order{
OrderID: <span class="string">"123"</span>,
ClientID: <span class="string">"456"</span>,
Amount: <span class="number">100.0</span>,
Currency: <span class="string">"USD"</span>,
ClientEmail: <span class="string">"client@example.com"</span>,
} }
func main() { jsonValue, _ := json.Marshal(order)
order := &Order{ _, err := http.Post("{{host}}/order", <span class="string">"application/json"</span>, bytes.NewBuffer(jsonValue))
OrderID: "123", <span class="keyword">if</span> err != <span class="keyword">nil</span> {
ClientID: "456", <span class="comment">// handle error</span>
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
}
} }
</code> }
</pre> </code>
</pre>
<h4>Node.js</h4> <h4>Node.js</h4>
<pre> <pre>
<code> <code>
const axios = require('axios'); <span class="keyword">const</span> axios = <span class="keyword">require</span>(<span class="string">'axios'</span>);
const order = { <span class="keyword">const</span> order = {
order_id: '123', order_id: <span class="string">'123'</span>,
client_id: '456', client_id: <span class="string">'456'</span>,
amount: 100.0, amount: <span class="number">100.0</span>,
currency: 'USD', currency: <span class="string">'USD'</span>,
client_email: 'client@example.com' client_email: <span class="string">'client@example.com'</span>
}; };
axios.post('{{host}}/order', order) axios.post(<span class="string">'{{host}}/order'</span>, order)
.then(response => { .then(response => {
console.log(response.data); console.log(response.data);
}) })
.catch(error => { .catch(error => {
console.error(error); console.error(error);
}); });
</code> </code>
</pre> </pre>
<h4>CURL</h4> <h4>CURL</h4>
<pre> <pre>
<code> <code>
curl -X POST {{host}}/order \ curl -X POST <span class="string">{{host}}/order</span> \
-H 'Content-Type: application/json' \ -H <span class="string">'Content-Type: application/json'</span> \
-d '{ -d <span class="string">'{
"order_id": "123", "order_id": "123",
"client_id": "456", "client_id": "456",
"amount": 100.0, "amount": 100.0,
"currency": "USD", "currency": "USD",
"client_email": "client@example.com" "client_email": "client@example.com"
}' }'</span>
</code> </code>
</pre> </pre>
<h3>Handling the Response</h3> <h3>Handling the Response</h3>
<p>The response from the /order endpoint is an HTML page that should be displayed to the user. This can be done <p>The response from the /order endpoint is an HTML page that should be displayed to the user. This can be done