Including context objects through multiple HTTP handlers in golang

前端 未结 2 1436
不知归路
不知归路 2021-02-06 11:46

I just read this blog post about creating a function type and implementing the .ServeHTTP() method on that function to be able to handle errors. For example:

<
2条回答
  •  面向向阳花
    2021-02-06 12:23

    Use r.Context(), which is available since Go 1.7.

    See https://golang.org/pkg/net/http/#Request.Context

提交回复
热议问题