https://github.com/liedsonfsa/go-rest-api
https://github.com/liedsonfsa/go-rest-api
gin-gonic golang jwt
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/liedsonfsa/go-rest-api
- Owner: Liedsonfsa
- Created: 2025-02-19T17:33:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-27T16:53:49.000Z (over 1 year ago)
- Last Synced: 2025-02-27T23:41:14.125Z (over 1 year ago)
- Topics: gin-gonic, golang, jwt
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rest API in Go 
This is an API that is capable of managing events, thus being able to create, remove and update events. It is also possible to register users for events and remove a user's registration from an event.
## Cloning and accessing the repository
```bash
git clone https://github.com/Liedsonfsa/go-rest-api.git
cd go-rest-api
```
## Downloading dependencies
```go
go mod downloading
```
## Environment variables
Create a .env file with the following variables
```bash
SECRET_KEY= # secrete key for signing jwt tokens
DB_NAME= # database name
DB_USER= # database user
DB_PASSWORD= # database password
```
## Running the API
```go
go run main.go
```
## Routes that do not require authentication
```bash
GET {host}/events # searching for all events
```
```bash
GET {host}/events/id # searching for an event by id
```
```bash
POST {host}/signup # registering a new user
```
```bash
POST {host}/login # user login
```
## Routes that require authentication
```bash
POST {host}/events # creating a new event
```
```bash
PUT {host}/events/id # updating a specific event
```
```bash
DELETE {host}/events/id # deleting a specific event
```
```bash
POST {host}/events/id/register # registering a user in a specific event
```
```bash
DELETE {host}/events/id/register # deleting a user's record of a given event
```
#### Examples of how routes are used are in the folder `/api-test`
#### To perform requests using the files contained in the `/api-test` folder, the `REST Client` extension is required.

#### After installing the extension, open some test file and click `Send Request`

## Technologies
- Go
- Gin
- MySQL
- JWT