Categorygithub.com/arafat-hasan/RESTful-API-with-Go
modulepackage
0.0.0-20240209124424-83822463b456
Repository: https://github.com/arafat-hasan/restful-api-with-go.git
Documentation: pkg.go.dev

# README

Learning RESTful API with Go

Simple RESTful API to create, read, update and delete books with MongoDB.

Prepare Development Environment

docker compose -f docker-compose-dev.yml up -d

Now click on the "Attach to the running container" on VS Code.

go build
./go_restapi

Endpoints

GET

http://localhost:8000/books

POST

URL

http://localhost:8000/books

Body

{
"isbn":"4545454",
"title":"First Three",
"author":{"firstname":"Harry",  "lastname":"White"}
}

Header:

Key:Value
Content-Type:application/json

PUT

URL

http://localhost:8000/books/{specific-id}

Body

{
"isbn":"777777777777",
"title":"Updated Three",
"author":{"firstname":"Harry",  "lastname":"White"}
}

Header:

Key:Value
Content-Type:application/json

DELETE

URL

http://localhost:8000/books/{id}

Acessing secure apis:

  • Obtain a JWT token here: /static/authenticate.html
    • Enter username:password > admin:12345,member:12345
    • The response contains a JWT token for that program
  • Use the token when calling any secure api:
    • set the Authorization request header and add the jwt token, like so:
    • Authorization: Bearer <token>

# Functions

No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author