You're reading a sample of this book. Get the full version here.
Let's Go Further › Introduction
Previous · Contents · Next
Chapter 1.

Introduction

In this book we’re going to work through the start-to-finish build of an application called Greenlight — a JSON API for retrieving and managing information about movies. You can think of the core functionality as being a bit like the Open Movie Database API.

Ultimately, our Greenlight API will support the following endpoints and actions:

Method URL Pattern Action
GET /v1/healthcheck Show application health and version information
GET /v1/movies Show the details of all movies
POST /v1/movies Create a new movie
GET /v1/movies/:id Show the details of a specific movie
PATCH /v1/movies/:id Update the details of a specific movie
DELETE /v1/movies/:id Delete a specific movie
POST /v1/users Register a new user
PUT /v1/users/activated Activate a specific user
PUT /v1/users/password Update the password for a specific user
POST /v1/tokens/authentication Generate a new authentication token
POST /v1/tokens/password-reset Generate a new password-reset token
GET /debug/vars Display application metrics

To give you an idea of what the API will look like from a client’s point of view, by the end of this book the GET /v1/movies/:id endpoint will return a response similar this:

$ curl -H "Authorization: Bearer RIDBIAE3AMMK57T6IAEBUGA7ZQ" localhost:4000/v1/movies/1
{
    "movie": {
        "id": 1,
        "title": "Moana",
        "year": 2016,
        "runtime": "107 mins",
        "genres": [
            "animation",
            "adventure"
        ],
        "version": 1
    }
}

Behind the scenes, we’ll use PostgreSQL as the database for persistently storing all the data. And at the end of the book, we’ll deploy the finished API to a Linux server running on Digital Ocean.

Conventions

Code blocks in this book are shown with a silver background, like the example below. If a code block is particularly long, any parts that aren’t relevant may be replaced with an ellipsis. To make it easy to follow along, most code blocks also have a title bar at the top indicating the name of the file that the code is in. Like this:

File: hello.go
package main

... // Indicates that some existing code has been omitted.

func sayHello() {
    fmt.Println("Hello world!")
}

Terminal (command line) instructions are shown with a black background and generally start with a dollar symbol. These commands should work on any Unix-based operating system, including macOS and Linux. Sample output is shown in silver beneath the command, like so:

$ echo "Hello world!"
Hello world!

If you’re using Windows, you should replace these commands with the DOS equivalent or carry out the action via the normal Windows GUI.

Please note that the dates and timestamps shown in screenshots and the example output from commands are illustrative only. They do not necessarily align with each other, or progress chronologically throughout the book.

Some chapters in this book end with an additional information section. These sections contain information that isn’t relevant to our application build, but is still important (or sometimes, just interesting) to know about.

About the author

Hey, I’m Alex Edwards, a full-stack web developer and author. I live near Innsbruck, Austria.

I’ve been working with Go for over 10 years, building production applications for myself and commercial clients, and helping people all around the world improve their Go skills.

You can see more of my writing on my blog (where I publish detailed tutorials), some of my open-source work on GitHub, and you can also follow me on Instagram and Twitter.

Let’s Go Further. Copyright © 2024 Alex Edwards.

Last updated 2024-08-19 09:43:46 UTC. Version 1.23.0.

The Go gopher was designed by Renee French and is used under the Creative Commons 3.0 Attributions license. Cover gopher adapted from vectors by Egon Elbre.

The information provided within this book is for general informational purposes only. While the author and publisher have made every effort to ensure that the accuracy of the information within this book was correct at time of publication there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this book for any purpose. Any use of this information is at your own risk.