feat: add host as parameter to index

This commit is contained in:
Urko 2023-07-20 08:50:24 +02:00
parent 56c9d2e320
commit 80ffe559ef
2 changed files with 6 additions and 4 deletions

View File

@ -121,7 +121,7 @@
} }
jsonValue, _ := json.Marshal(order) jsonValue, _ := json.Marshal(order)
_, err := http.Post("https://yourwebsite.com/order", "application/json", bytes.NewBuffer(jsonValue)) _, err := http.Post("{{host}}/order", "application/json", bytes.NewBuffer(jsonValue))
if err != nil { if err != nil {
// handle error // handle error
} }
@ -142,7 +142,7 @@
client_email: 'client@example.com' client_email: 'client@example.com'
}; };
axios.post('https://yourwebsite.com/order', order) axios.post('{{host}}/order', order)
.then(response => { .then(response => {
console.log(response.data); console.log(response.data);
}) })
@ -155,7 +155,7 @@
<h4>CURL</h4> <h4>CURL</h4>
<pre> <pre>
<code> <code>
curl -X POST https://yourwebsite.com/order \ curl -X POST {{host}}/order \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{ -d '{
"order_id": "123", "order_id": "123",

View File

@ -138,7 +138,9 @@ func (s *RestServer) loadViews(imagesDir string) {
s.app.Static("/images", imagesDir) s.app.Static("/images", imagesDir)
s.app.Get("/", func(c *fiber.Ctx) error { s.app.Get("/", func(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{}) return c.Render("index", fiber.Map{
"host": s.config.Host,
})
}) })
s.app.Get("/error", func(c *fiber.Ctx) error { s.app.Get("/error", func(c *fiber.Ctx) error {