go-echo

Close all goroutines when HTTP request is cancelled

大城市里の小女人 提交于 2020-01-14 06:50:12
问题 I am making a web crawler. I'm passing the url through a crawler function and parsing it to get all the links in the anchor tag, then I am invoking same crawler function for all those urls using seperate goroutine for every url. But if if send a request and cancel it before I get the response, all the groutines for that particular request are still running. Now what I want is that when I cancel the request all the goroutines that got invoked due to that request stops. Please guide. Following

Serving files with Echo

眉间皱痕 提交于 2019-12-23 04:58:04
问题 I'm trying to serve multiple files with Echo, but it doesn't work every time. The api code looks like this: package main import ( "github.com/labstack/echo" "net/http" ) func main() { e := echo.New(); e.GET("/", home); e.File("/data1", "assets/data1.csv"); e.File("/data2", "assets/data2.csv"); e.Logger.Fatal(e.Start(":4243")); } func home(c echo.Context) error { return c.String(http.StatusOK, "Are you lost?"); } To be precise, it does work for the very first file fetching, but then keeps