https://github.com/ishtiaqhimel/go-api-server
API Server
https://github.com/ishtiaqhimel/go-api-server
docker golang jwt rest-api
Last synced: 5 months ago
JSON representation
API Server
- Host: GitHub
- URL: https://github.com/ishtiaqhimel/go-api-server
- Owner: ishtiaqhimel
- License: other
- Created: 2022-11-28T13:08:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-13T06:24:46.000Z (over 1 year ago)
- Last Synced: 2025-04-08T21:35:35.026Z (about 1 year ago)
- Topics: docker, golang, jwt, rest-api
- Language: Go
- Homepage:
- Size: 250 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# API server Using Go
[](https://goreportcard.com/report/github.com/ishtiaqhimel/go-api-server)
### RESTful API using [go](https://github.com/golang), [cobra CLI](https://github.com/spf13/cobra), [go-chi/chi](https://github.com/go-chi/chi), Basic Auth, [JWT Auth](https://github.com/dgrijalva/jwt-go)
---
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:
* [sysdevbd learn GO](https://sysdevbd.com/go/)
* [A Beginner’s Guide to HTTP and REST](https://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340)
* [HTTP Response Status Codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)