Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Echo Quick Start Guide
Echo Quick Start Guide

Echo Quick Start Guide: Build lightweight and high-performance web apps with Echo

Arrow left icon
Profile Icon Ben Huson
Arrow right icon
NZ$14.99 NZ$31.99
eBook May 2018 136 pages 1st Edition
eBook
NZ$14.99 NZ$31.99
Paperback
NZ$39.99
Subscription
Free Trial
Arrow left icon
Profile Icon Ben Huson
Arrow right icon
NZ$14.99 NZ$31.99
eBook May 2018 136 pages 1st Edition
eBook
NZ$14.99 NZ$31.99
Paperback
NZ$39.99
Subscription
Free Trial
eBook
NZ$14.99 NZ$31.99
Paperback
NZ$39.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Echo Quick Start Guide

Developing Echo Projects

Of the most compelling reasons to use a web application framework for a project, the most important is that it offers clean, organized code. Frameworks offer defined structure for application development, as well as helpful functionality that minimizes the energy the developer has to use to create an application. Within an Echo project, the developer has the flexibility in implementation and project structure.

We will begin by diving into an example of an Echo project. Once we have the basic directory structure of our application defined, and the reasoning for the structure in place, we will begin to explore some fundamental building blocks and features of Echo in our example project. Firstly, we will cover target-path routing and application-handler development. Then, we will explain a high-level overview of the most commonly used features within Echo...

Technical requirements

Setting up a project in echo and organizing code

The best way to learn is by example in my opinion, so, to that end, we will walk through the initial creation of an application to best showcase the Echo framework. The source code for our sample project for this chapter is located here: https://github.com/PacktPublishing/Echo-Essentials/tree/master/chapter2. The following is a preliminary use-case diagram showing the interactions we will be creating, which will help us develop this project:

Regardless of the particulars of the project, organization of code is paramount for the success of the project. When we are developing a Go web application with Echo, it helps to start your project with a strong directory structure. A well-thought-out structure limits the number of issues with cyclical imports, and will allow you to create a clean in-project dependency tree. The organization...

Routing and handlers

When we think of routing, we often think of networking routers that send traffic on networks to their destinations. For the purposes of this book, when the term routing is used, the topic is how to map a target path to a handler function. There are many ways to do this, each with benefits and drawbacks. Sometimes, all you need is a static mapping of a target path string, such as /reminder to a function called CreateReminder. Then, any time a user visits your application with a target path of /reminder, your CreateReminder function will be triggered.

What happens, though, if you want to have a URL variable within the URL? For example, if we wanted to have /reminder/123 relate to a reminder resource with an ID of 123. It would be impractical to have all of the reminder IDs within the entire system mapped out by our target path router. You may consider performing...

Middleware

Sometimes, there are use cases where the same application logic needs to be applied to a multitude of resources within an application. A prime example of this type of logic is protecting resources behind an authentication mechanism. Some resources such as the login or static resources typically do not need this authentication logic, but other resources such as our reminder creation, snoozing, need to be protected by authentication. We can accomplish this feat with the use of middleware.

A middleware can be thought of as a wrapper for the handlers we create. An Echo middleware is defined as a function that takes the next function to call as a parameter, and returns an Echo handler. By having the parameter be the next handler function to call, we are able to build a chain of handlers:

...

Rendering

As mentioned previously, the job of a web application or an API is to create an HTTP response message, given an HTTP request message. Echo has a really nice facility to help us render responses from our handlers and middleware functions. echo.Context has methods which perform all of the heavy hitting for rendering responses back to the caller. As seen in prior examples, there is a JSON method on the Echo Context which allows for rendering of a JSON payload back to the caller. The following is a list of supported rendering capabilities within Echo:

  • HTML: Render an HTML response:

    • HTMLBlob: Render a preformed HTML response

  • JSON: Render a JSON response, converting the variable into JSON based on the struct tags of the variable:

    • JSONBlob: Render a preformed JSON response

    • JSONPretty: Render a pretty JSON response

    • JSONP: Render a JSONP response based on the struct...

Summary

Within this whirlwind chapter, much was covered about setting up an Echo project, as well as fundamentals of developing within the Echo framework. Some primary features of the framework were discussed, and examples were used to expose the reader to the concepts.

It is clear, based on the examples that were used within this chapter, that the most important aspect for a successful web application is the code's layout and organization. We are able to focus more on the particular application logic associated with our application by using the Echo framework. There is less need to find solutions to already solved problems such as request middleware pipelines, routing of URL paths to application handlers, and taking input and rendering output effectively.

In the remainder of the book, we will be looking at the features of the Echo framework in greater depth. In the next...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • The easiest way to learn how to build web apps with Echo
  • Build a full working project
  • For Go developers with only basic web development knowledge required

Description

Echo is a leading framework for creating web applications with the Go language.  This book will show you how to develop scalable real-world web apps, RESTful services, and backend systems with Echo.  After a thorough understanding of the basics, you'll be introduced to all the concepts for a building real-world web system with Echo. You will start with the the Go HTTP standard library, and setting up your work environment. You will move on to Echo handlers, group routing, data binding, and middleware processing. After that, you will learn how to test your Go application and use templates.  By the end of this book you will be able to build your very own high performance apps using Echo. A Quick Start Guide is a focussed, shorter title which provides a faster paced introduction to a technology. They are for people who don’t need all the detail at this point in their learning curve. The presentation has been streamlined to concentrate on the things you really need to know, rather than everything.

Who is this book for?

You will need to know the basics of the Go language, and the general concepts of web development.

What you will learn

  • Key design considerations for high performance Echo applications
  • How Echo handles routing
  • How context is managed through the lifetime of the request and response pipeline
  • Decrease complexity of your apps by developing middleware functions
  • Interact with the request through request data bindings
  • Interact with the response through response data renderings within the framework
  • Use Echo s logging and error handling facilities
  • Render Go templates within Echo to allow for server side rendering of content

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 30, 2018
Length: 136 pages
Edition : 1st
Language : English
ISBN-13 : 9781789131123
Vendor :
Amazon
Category :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 30, 2018
Length: 136 pages
Edition : 1st
Language : English
ISBN-13 : 9781789131123
Vendor :
Amazon
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just NZ$7 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total NZ$ 169.97
Echo Quick Start Guide
NZ$39.99
Alexa Skills Projects
NZ$64.99
Hands-On Chatbots and Conversational UI Development
NZ$64.99
Total NZ$ 169.97 Stars icon
Banner background image

Table of Contents

9 Chapters
Understanding HTTP, Go, and Echo Chevron down icon Chevron up icon
Developing Echo Projects Chevron down icon Chevron up icon
Exploring Routing Capabilities Chevron down icon Chevron up icon
Implementing Middleware Chevron down icon Chevron up icon
Utilizing the Request Context and Data Bindings Chevron down icon Chevron up icon
Performing Logging and Error Handling Chevron down icon Chevron up icon
Testing Applications Chevron down icon Chevron up icon
Providing Templates and Static Content Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.