Set, Plan, GO!

S

Setting the stage

There are many ways to skin this cat, the most important is where to find it https://go.dev/doc/install

The options for coding these days are too numerous for me to list in this post, and frankly, however you choose to drink this poison is up to you. Personally, I am using JetBrains GoLand. Maybe you’re using GitHub’s Codespaces. As long as you can run Go and successfully communicate with it by using your favorite API platform (mine is Postman), then that’s cool with me.

Act 1 – The plan

To recap, the business Inflatable-Heros Corp (IH), wants to start selling their wares. Imagine they have a warehouse full of things, and all they need right now is a system to record, retrieve, and edit these inflatables.

For that, we are going to need some CRUD endpoints (Create, Read, Update, Delete). These verbs will be the actions of our endpoints related to the entity or object.

To keep it simple, think of it like physically going into a store and our role within. As we need to cover all bases, we are the supreme lord of IH, nothing is beyond our powers!

With that in mind, when we enter this space of unimaginable potential, we need ways to interact with the items we are selling:

  • List of Products: GET /products to retrieve a list of all inflatable hero products.
  • Product Details: GET /products/{id} to retrieve details of a specific inflatable hero.
  • Create Product: POST /products to add a new inflatable hero to the catalog.
  • Update Product: PUT /products/{id} to update an existing inflatable hero’s details.
  • Delete Product: DELETE /products/{id} to remove an inflatable hero from the catalog.
  • Like a Product: POST /products/{id}/like to like a specific inflatable hero, indicating customer interest.

We also need to define the properties of the item:

{
  "id": "hero123",
  "name": "Super Balloon",
  "description": "A life-size inflatable superhero with super strength and flying abilities.",
  "category": "Superhero",
  "price": 29.99,
  "likesCount": 150,
  "availability": true,
  "dimensions": {
    "height": "6 feet",
    "width": "3 feet"
  },
  "materials": ["Polyvinyl Chloride", "ABS Plastic"],
  "tags": ["superhero", "durable", "outdoor"],
  "imageUrl": "http://example.com/images/super_balloon.jpg"
}

This JSON object includes:

  • id: A unique identifier for each inflatable hero.
  • name: The name of the inflatable hero.
  • description: A brief description of the hero.
  • category: The category or type of hero.
  • price: The selling price.
  • likesCount: A count of how many likes this product has received.
  • availability: A boolean indicating if the product is in stock.
  • dimensions: An object containing the height and width of the product.
  • materials: An array listing the materials used in the product.
  • tags: An array of descriptive tags for search optimization.
  • imageUrl: A URL pointing to an image of the inflatable hero.


With these elements, we should be in a good place to get started.

Thanks a bunch,
Ryan

About the author

admin-blog

Add comment

By admin-blog

Recent Comments

No comments to show.