Skip to content

Make Endpoint API using Golang, Mux Library, MySQL, and Redis

Notifications You must be signed in to change notification settings

fjasper13/endpoint-article

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EndPoint API (Create and Read)

I'm Using Golang, Mux Library, MySQL, and Redis

Golang Documentation : https://go.dev/doc/
Golang Instalation : https://go.dev/doc/install
Redis Instalation : https://redis.io/download

How To Run The Code

  1. Adjust the .env File According to Your Need
  2. Make MySQL Database According to .env File
  3. Type go run main.go In Your Terminal

EndPoint Documentation (Using Postman)

Get All Articles

  1. standart response

http://localhost:8000/articles

  1. pagination response: Example to Add in Params:
    key: page, value: 1
    key: per_page , value:3
    key: paginate , value:1 (true or false for using pagination response)

http://localhost:8000/articles?page=1&per_page=3&paginate=1

  1. sort by {collumn} (default sort by last created_at ) Example to Add in Params:
    key: sort , value author|asc -> for asc
    key: sort , value author|desc -> for desc

http://localhost:8000/articles?sort=author|asc

  1. search any word in title or body Example to Add in Params:
    key: search , value:GolangCoding

http://localhost:8000/articles?search=GolangCoding

  1. filter by {column} (can add more than 1 filter) Example to Add in Params:
    key:filter[] , value:{"option":"author","operator":"=","value":"jasper"}
    key:filter[] , value:{"option":"title","operator":"=","value":"GolangCoding"}

http://localhost:8000/articles?filter[]={"option":"author","operator":"=","value":"jasper"}&filter[]={"option":"title","operator":"=","value":"GolangCoding"}

Get Single Article

  1. Run redis server first

redis-server

  1. Check redis server

redis-cli ping

  1. Endpoint Get Single Article

http://localhost:8000/articles/{article_id}

Post Single Article

http://localhost:8000/articles

body: { "author": "Jasper", "title": "Golang Code", "body": "This is a Body of Golang Code Article" }

About

Make Endpoint API using Golang, Mux Library, MySQL, and Redis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published