You’ve designed your API and implemented the service methods. Now it’s time to run the Concerts service and test its endpoints.
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
).
Let’s explore your shiny new API! You can interact with your service using popular HTTP tools:
curl
for quick command-line testingPick 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:
POST
)GET
)GET
)PUT
)DELETE
)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
}'
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"
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>
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"
}'
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>
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.
Prerequisites
Start Swagger UI
docker run -p 8081:8080 swaggerapi/swagger-ui
View Documentation
http://localhost:8081
in your browserhttp://localhost:8080/openapi3.yaml
in the Swagger UINow 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.