Last active
February 10, 2020 15:12
-
-
Save karolhrdina/56e01bd1554fe1b83aba3bc09cae95bc to your computer and use it in GitHub Desktop.
Question about echo server
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/labstack/echo/v4" | |
) | |
func main() { | |
// Echo instance | |
e := echo.New() | |
// Routes | |
e.POST("/:product/foo/bar", recovery) | |
e.GET("/hello/world", hello) | |
// Start server | |
e.Logger.Fatal(e.Start(":1323")) | |
} | |
func recovery(c echo.Context) error { | |
product := c.Param("product") | |
return c.String(http.StatusOK, fmt.Sprintf("Product '%s' recovered", product)) | |
} | |
func hello(c echo.Context) error { | |
return c.String(http.StatusOK, "Hello, World!") | |
} |
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
#!/bin/bash | |
# This works | |
curl -XGET localhost:1323/hello/world | |
# This works | |
curl -XPOST localhost:1323/hatatitla/foo/bar | |
# Following two calls don't work (they hang the echo server) | |
curl -XPOST localhost:1323/hatatitla/foo/barsomethigelse | |
curl -XGET localhost:1323/hello/worldabrakadabra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment