Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Echo Quick Start Guide

You're reading from   Echo Quick Start Guide Build lightweight and high-performance web apps with Echo

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781789139433
Length 136 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ben Huson Ben Huson
Author Profile Icon Ben Huson
Ben Huson
Arrow right icon
View More author details
Toc

Maintaining context

Throughout early Go web application development, there was much contention surrounding how to weave together context when chaining handler function calls together. If we examine the standard library http.HandlerFunc definition, type HandlerFunc func(ResponseWriter, *Request), this type is not conducive for building a chained middleware scheme, or calling other request handlers from within handlers whatsoever. This is because of the two different parameters, http.ResponseWriter and *http.Request. The http.ResponseWriter is an interface that is designed primarily to write a sequence of bytes back to the caller, whereas the second parameter, the *http.Request, is a pointer to the data structure that represents the request.

Prior to Go 1.7, there was no mechanism in place within the http.Request type to store extra information to keep the state from one nested...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image