Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Echo Quick Start Guide

You're reading from  Echo Quick Start Guide

Product type Book
Published in May 2018
Publisher Packt
ISBN-13 9781789139433
Pages 136 pages
Edition 1st Edition
Languages
Author (1):
Ben Huson Ben Huson
Profile icon Ben Huson

Preface

This tour of web application development aims to express the capabilities required of a development framework, and also considers what is truly important for developer efficiency within the field of web application development. Starting with the basics of HTTP and progressing through the built-in features of Echo, we explore together how best to create, organize, and maintain a successful web application.

The plethora of Go web application frameworks currently in the wild is staggering, causing even experienced web application developers paralysis of analysis. Each web application framework out there has been subtly optimized for the particular use cases of the group of authors contributing to it. There are so many opinionated options out there that developers often choose one framework for their applications and figure out that the features of the framework do not align with the developer. Oftentimes, the lack of feature functionality or performance are limiting factors as well for adoption of a web application framework.

This book focuses on general web application development concepts framed within the Echo framework. We start by exploring general HTTP concepts and move onto how these concepts are fulfilled by the built-in features of Echo. In addition, this book explores exactly how Echo achieves performance and functional goals by diving deep into the particulars of how the features are implemented. This book aims to give a clear representation of the essential functionalities and features within Echo in order to provide developers not only with reasons to choose Echo, but to provide real examples of Echo in action, demonstrating how developer efficiency is improved.

Within this book, you will learn about the internal concepts of handler routing, middleware chaining, and maintaining context. We will demonstrate how you as a developer will increase efficiency through interacting with Echo for request binding and response rendering. You will be shown how to effectively log and handle errors, as well as how to create unit tests for your application. By looking at the essentials of the Echo framework, you will be equipped to make a positive impact in your development team.

This book is referenced as Echo Essentials in the GitHub repository and code videos.

Who this book is for

Software developers who are fairly new to Go and are looking to employ a high-performance web application or backend API will be most rewarded by this book. Developers who have a performance requirement for their APIs and developers who have some Go experience, as well as experience with web application frameworks in general but not with Echo, will also benefit.

We assume that the reader will be well-versed in web technologies, with a basic understanding of the HTTP protocol and REST API design concepts. We further assume that the reader will have worked with another backend web application framework before and understands the processing pipelines that are common in web frameworks.

What this book covers

Chapter 1, Understanding HTTP, Go, and Echo, covers a high-level understanding of HTTP, Go, and the Echo framework. We explain how the Go HTTP standard library is structured and what useful primitives are included. By reviewing what features the standard library contains for HTTP requests, responses, and handling of requests, how using a web framework can improve the quality and robustness of your application will be evident. Also covered are some of the internals of the standard library web server and comparisons with Echo. Finally, we also cover initial environment setup in order for the reader to become immediately productive.

Chapter 2, Exploring Routing Capabilities, dives into a very fast and high-level tour of the major functionality of the Echo framework, and discusses around an optimal Echo project setup. Starting with the most basic Echo handler and working through an example application, we show the features and capabilities of Echo very briefly.

Chapter 3, Implementing Middleware, discusses one of the most common problems in web application development, which is how to appropriately map the resource described in the URL path to the actual code that represents the resource. Within this chapter, we will explain how Echo's routing engine works and provide real examples of how the routing capabilities within Echo perform better than other web frameworks in the space.

Chapter 4, Developing Echo Projects, covers request and response processing pipelines within Echo. By using middleware, we show how you can simplify your handler code by breaking handler units of work into middleware functions. We also explain how middleware chaining works and what to expect when you use middleware in Echo.

Chapter 5, Utilizing the Request Context and Data Bindings, explains how context is used within the Echo framework. Context within the Echo framework allows for simplification of otherwise difficult information passing. Since context is built into the handler function signature, your code will always have access to this construct. This chapter also investigates a few mechanisms related to the context, which are request binding and response rendering. The chapter shows examples of how to accomplish as well as some related best practices.

Chapter 6, Performing Logging and Error Handling, exposes to the reader an often-overlooked but critically important aspect of application design: logging and error handling. This chapter provides real examples of how logging and error handling can work within your Echo-based web applications.

Chapter 7, Testing Applications, marches into effective testing techniques for testing a web application API. We will start with some definitions of various forms of testing and then progress into test implementations. There are also neat tricks shown within the chapter to provide you with more information about coverage numbers from external testing.

Chapter 8, Providing Templates and Static Content, goes over how to interact with Echo's file serving capabilities in order to provide static content to your callers. By building on Go's html/template package, we also go into depth on how to make the most of dynamic template rendering.

To get the most out of this book

  • An intermediate knowledge of the Go programming language as well as initial exposure to web application frameworks
  • Ability to develop with an IDE and cursory experience on the command line

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Echo-Essentials. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Code in Action

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The parameters include two string arguments, method and path, as well as an echo.HandlerFunc variable for which the resulting request routing match should map."

A block of code is set as follows:

func (e *Echo) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {

Any command-line input or output is written as follows:

mkdir -p $GOPATH/src/github.com/PacktPublishing

git clone https://github.com/PacktPublishing/Echo-Essentials

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

lock icon The rest of the chapter is locked
Next Chapter arrow right
You have been reading a chapter from
Echo Quick Start Guide
Published in: May 2018 Publisher: Packt ISBN-13: 9781789139433
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 $15.99/month. Cancel anytime}