Running the Concerts Service

Learn how to run your Goa-based Concerts service, test the REST endpoints using HTTP requests, and explore the auto-generated OpenAPI documentation.

You’ve designed your API and implemented the service methods. Now it’s time to run the Concerts service and test its endpoints.

1. Start the Server

From your project root, build and run your app:

go run concerts/cmd/concerts

The service listens on port 8080 by default (unless modified in main.go).

2. Test the Endpoints

Let’s explore your shiny new API! You can interact with your service using popular HTTP tools:

  • curl for quick command-line testing
  • HTTPie for a more user-friendly CLI experience
  • Postman for a powerful GUI interface with request history and collections

Pick your favorite tool and let’s start making some requests! 🚀 We’ll use curl for these examples since it’s universally available on most systems. However, feel free to adapt the examples to your preferred HTTP client, the concepts remain the same regardless of the tool you use.

Here’s what we’ll test:

  • Creating a new concert (POST)
  • Listing all concerts with pagination (GET)
  • Retrieving a specific concert (GET)
  • Updating concert details (PUT)
  • Deleting a concert (DELETE)

Create a Concert

Let’s create a new concert! This request sends a POST with the concert details in JSON format. The server will generate a unique ID and return the complete concert object:

curl -X POST http://localhost:8080/concerts \
  -H "Content-Type: application/json" \
  -d '{
    "artist": "The Rolling Stones",
    "date": "2025-05-01",
    "venue": "Wembley Stadium",
    "price": 150
  }'

Let’s create another one to illustrate pagination:

curl -X POST http://localhost:8080/concerts \
  -H "Content-Type: application/json" \
  -d '{
    "artist": "Pink Floyd",
    "date": "2025-07-15", 
    "venue": "Madison Square Garden",
    "price": 200
  }'

List Concerts

Get all concerts with optional pagination parameters:

  • page: Page number (default: 1)
  • limit: Results per page (default: 10, max: 100)

The list endpoint supports pagination to help you manage large sets of concert data efficiently. You can control how many results you see per page and which page to view.

Retrieve all concerts (uses default pagination):

curl http://localhost:8080/concerts

Get one result per page:

curl "http://localhost:8080/concerts?page=1&limit=1"

Show a Concert

When you need detailed information about a specific concert, use the show endpoint. This is useful for displaying individual concert details or verifying information after creation/updates.

Replace <concertID> with an ID returned from create:

curl http://localhost:8080/concerts/<concertID>

Update a Concert

Need to change concert details? The update endpoint lets you modify existing concert information. You only need to include the fields you want to update - other fields will retain their current values.

curl -X PUT http://localhost:8080/concerts/<concertID> \
  -H "Content-Type: application/json" \
  -d '{
    "artist": "The Beatles",
    "venue": "Madison Square Garden"
  }'

Delete a Concert

If a concert needs to be removed from the system (perhaps it was cancelled or entered by mistake), use the delete endpoint. This operation is permanent, so use it with care!

curl -X DELETE http://localhost:8080/concerts/<concertID>

3. Access API Documentation

Goa automatically generates OpenAPI documentation for your API in both version 2.x and 3.0.0 formats. These files are located in the gen/http/ directory.

Using Swagger UI

Alternative Documentation Tools

  • Redoc: Another popular OpenAPI documentation viewer
  • OpenAPI Generator: Generate client libraries in various languages
  • Speakeasy: Generate SDKs with enhanced developer experience

Next Steps

Now that you’ve explored the basic API operations, learn more about how Goa handles HTTP encoding and decoding to understand how requests and responses are processed.