8000 GitHub - allguitars/Go-REST-API: My first implementation of REST API with Golang.
[go: up one dir, main page]

Skip to content

allguitars/Go-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Golang: REST API

Implementation of REST APIs in Golang -- a book management system that has five route handlers:

  • Get all books (GET)
  • Get a single book with ID (GET)
  • Create a new book (POST)
  • Update the book with ID (PUT)
  • Delete a book with ID (DELETE)

Endpoints

	r.HandleFunc("/api/books", getBooks).Methods("GET")
	r.HandleFunc("/api/books/{id}", getBook).Methods("GET")
	r.HandleFunc("/api/books", createBook).Methods("POST")
	r.HandleFunc("/api/books/{id}", updateBook).Methods("PUT")
	r.HandleFunc("/api/books/{id}", deleteBook).Methods("DELETE") 

Mock Data

// Mock data - @todo: implement DB
	books = append(books, Book{
		ID:     "1",
		Isbn:   "33456",
		Title:  "Book One",
		Author: &Author{Firstname: "Jane", Lastname: "Doe"}})
	books = append(books, Book{
		ID:     "2",
		Isbn:   "54678",
		Title:  "Book Two",
		Author: &Author{Firstname: "David", Lastname: "Tao"}})

Tutorial

Check out Traversy Media

About

My first implementation of REST API with Golang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0