What is this CONTEXT in Go lang when it talks about HTTP requests?

For some, this may be a dumb question. On the other hand, it is very important to me. I am new to Go programming, and when I read this Interchange of Values ​​between Middlewares and this Go Concurrency Templates: Context I couldn’t understand what they mean by context when they refer to common values ​​between middleware handlers or request handlers in general.

I was able to write a web framework with Go - Frodo . It was not perfect in many ways, it was a training experiment. As you can see, I'm not stupid. Just informed newcomer to Go lang.

Thank you in advance for a detailed explanation.

+4
source share
1 answer

At the beginning of this blog, I found a great explanation: HTTP request contexts and transition

Request contexts, for those new to terminology, are usually a way to transfer data along with an HTTP request because it is handled by the handlers (or middleware) that you wrote. This data can be a user identifier, a CSRF token, a network token, regardless of whether the user is registered or not - something typical of logic that you do not want to repeat again and again in each handler. If you've ever used Django, the request context is synonymous with the request.META dictionary.

+3
source

Source: https://habr.com/ru/post/1623291/


All Articles