Coder Social home page Coder Social logo

golangcrud's Introduction

Simple CRUD API with Go and Gorilla Mux

This is a simple CRUD (Create, Read, Update, Delete) API implemented in Go using the Gorilla Mux router.

Features

  • Retrieve a list of movies
  • Retrieve a single movie by ID
  • Create a new movie
  • Update an existing movie
  • Delete a movie by ID

Prerequisites

Make sure you have Go installed on your machine. You can download and install it from here.

Installation

  1. Clone the repository:

    git clone https://github.com/Yash-sudo-web/GolangCRUD
    
  2. Navigate to the project directory:

    cd GolangCRUD
    
  3. Build and run the application:

    go build . && ./crud
    

API Endpoints

  • GET /movies: Retrieve a list of all movies.
  • GET /movies/{id}: Retrieve a single movie by its ID.
  • POST /movies: Create a new movie.
  • PUT /movies/{id}: Update an existing movie by its ID.
  • DELETE /movies/{id}: Delete a movie by its ID.

Usage

You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:

  • Get all movies:

    curl http://localhost:8000/movies
    
  • Get a movie by ID:

    curl http://localhost:8000/movies/1
    
  • Create a new movie:

    curl -X POST -H "Content-Type: application/json" -d '{"isbn":"123456","title":"New Movie","director":{"firstname":"Jane","lastname":"Doe"}}' http://localhost:8000/movies
    
  • Update an existing movie:

    curl -X PUT -H "Content-Type: application/json" -d '{"isbn":"123456","title":"Updated Movie","director":{"firstname":"Jane","lastname":"Doe"}}' http://localhost:8000/movies/1
    
  • Delete a movie by ID:

    curl -X DELETE http://localhost:8000/movies/1
    

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.

golangcrud's People

Contributors

yash-sudo-web avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.