Skip to content

Latest commit

 

History

History
77 lines (63 loc) · 3.04 KB

README.md

File metadata and controls

77 lines (63 loc) · 3.04 KB

API-server

Simple api server for CRUD operation

Technology Used

  • Golang
  • Gorilla Mux
  • JWT Authentication
  • Cobra CLI

Running the server

Running the server from direct source code

git clone [email protected]:pritamdas99/API_server.git

Go to the API-server directory and run
go mod tidy
go mod vendor
go run . start or go run . start -p <choosen port>

or go mod tidy
go mod vendor
go run . start or go run . start -p <choosen port>

Data model


// For string a cricket players basic information
type Book struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	GenreIds []int  `json:"genreids"`
}

type Genre struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type User struct {
	ID       string `json:"id"`
	Password string `json:"password"`
}

api calls

Method url payload actions
GET http://localhost:8080/ No call home page and get new token
GET http://localhost:8080/getallbook No call all the books exist in data model
GET http://localhost:8080/getallgenre No call all the genres exist in data model
POST http://localhost:8080/addbook Yes add new book in the data model
POST http://localhost:8080/adduser Yes add new user in the data model
POST http://localhost:8080/addgenre Yes add new book in the data model
PUT http://localhost:8080/updatebook/{id} Yes update a specific book by calling with id
PUT http://localhost:8080/updategenre/{id} Yes update a specific genre by calling with id
POST http://localhost:8080/updateuser/{id} Yes add new user in the data model
POST http://localhost:8080/loginuser Yes login a user in the data model
DELETE http://localhost:8080/deletebook/{id} No delete a specific book by calling its id
DELETE http://localhost:8080/deletegenre/{id} No delete a specific book by calling its id

CAUTIONS

  • All the api call is authorized by JWT token. So we need to pass token as a cookie while calling methods(except for homepage request) by postman or curl.
  • A token can be generated by logging in.

Prometheus Stuff

    prometheus repo:
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    helm repo update
    
    promethgeus install
    helm install prometheus prometheus-community/kube-prometheus-stack
    
    Following link for configuration:
    https://prometheus.io/docs/tutorials/instrumenting_http_server_in_go/