Skip to content

ishtiaqhimel/go-api-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API server Using Go

Go Report Card

RESTful API using go, cobra CLI, go-chi/chi, Basic Auth, JWT Auth


API Endpoints

Endpoint Function Method StatusCode Auth
/api/login LogIn POST Success - 200, Failure - 401 Basic
/api/student StudentGet GET Success - 200, Failure - 401 JWT
/api/student StudentPost POST Success - 200, Failure - 401, 409 JWT
/api/student/{id} StudentUpdate PUT Success - 200, Failure - 401, 404 JWT
/api/student/{id} StudentDelete DELETE Success - 200, Failure - 401, 404 JWT
/api/subject SubjectGet GET Success - 200, Failure - 401 JWT
/api/subject SubjectPost POST Success - 200, Failure - 401, 409 JWT
/api/subject/{id} SubjectUpdate PUT Success - 200, Failure - 401, 404 JWT
/api/subject/{id} SubjectDelete DELETE Success - 200, Failure - 401, 404 JWT

Data Model

package model

type Student struct {
	Id        string    `json:"id"`
	FirstName string    `json:"firstName"`
	LastName  string    `json:"lastName"`
	Subjects  []Subject `json:"subjects"`
}

package model

type Subject struct {
	Id    string `json:"id"`
	Title string `json:"title"`
	Code  string `json:"code"`
}


Installation

  • go install github.com/ishtiaqhimel/go-api-server@latest

Run

  • go-api-server start

CLI Commands

  • build the app locally make build
  • help with the start commands ./bin/apiserver start -h or ./bin/apiserver start --help

Authentication Method

  • Basic Authentication
  • JWT Authentication

Resources: