recipes-api-go

command module
v0.0.0-...-cb6f23a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 10 Imported by: 0

README

Recipes API

A simple API for storing and retrieving recipes.

Prerequisites

  • Go
  • MySQL

Getting Started

  1. Clone the repository
  2. Copy config.sample.yaml to config.yaml and fill in your MySQL database details
  3. Run the following command to start the server:
go run .

Endpoints

GET /api/recipe/

Lists all recipes.

curl --location --request GET 'http://localhost:8080/api/recipe'
POST /api/recipe/

Creates a new recipe.

curl --location --request POST 'http://localhost:8080/api/recipe' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Spaghetti Carbonara",
    "enough_for": "4 servings",
    "origin": "Italy",
    "ingredients": "spaghetti, eggs, bacon, parmesan cheese, salt, black pepper",
    "description": "A classic Italian pasta dish",
    "kind": "pasta",
    "prep_time": "10 minutes",
    "difficulty": "easy",
    "notes": "",
    "cook_time": "15 minutes",
    "serving_size": "",
    "rating": "4.8"
}'
GET /api/recipe/:id

Gets a single recipe by ID.

curl --location --request GET 'http://localhost:8080/api/recipe/1'
PUT /api/recipe/:id

Updates a recipe by ID.

curl --location --request PUT 'http://localhost:8080/api/recipe/1' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Spaghetti Carbonara",
    "enough_for": "4 servings",
    "origin": "Italy",
    "ingredients": "spaghetti, eggs, bacon, parmesan cheese, salt, black pepper",
    "description": "A classic Italian pasta dish with a creamy sauce",
    "kind": "pasta",
    "prep_time": "10 minutes",
    "difficulty": "easy",
    "notes": "",
    "cook_time": "15 minutes",
    "serving_size": "",
    "rating": "4.8"
}'
DELETE /api/recipe/:id

Deletes a recipe by ID.

curl --location --request DELETE 'http://localhost:8080/api/recipe/1'

Credits

Created by Joe Harkins (jharkins) and OpenAI's ChatGPT.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL