handlers

package
v0.0.0-...-65940b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 5 Imported by: 0

README

SPAM BOT API Documentation

This documentation provides an overview of the SPAM BOT API, which is responsible for handling user authentication and managing user-related data. The API is built using the Gin framework in the Go programming language.

Getting Started

To set up and run the SPAM BOT API:

See in main Readme.md
The API will start running on `http://localhost:8080`.
// start api function, change port if u need
func InitAPI() {
    fmt.Print("api and client start")
    router := gin.Default()
    router.Use(cors.Default())
    
    apiRoutes := router.Group("/api/v1/auth")
    {
        apiRoutes.POST("/login", api.AuthLogin)
    }
    authedApiRoutes := router.Group("/api/v1").Use(middleware.AuthMiddleware())
	{
        authedApiRoutes.GET("/users", api.GetUsers)
        authedApiRoutes.POST("/users", api.CreateUser)
    }
    router.Run(":8080")
}

API Endpoints

  • POST /api/v1/auth/login

    • Description: Authenticates a user using an authorization code.
    • Request:
      {
        "code": "your_authorization_code"
      }
      
    • Response:
      {
        "access_token": "your_access_token",
        "refresh_token": "your_refresh_token"
      }
      
  • GET /api/v1/users

    • Description: Retrieves a list of users (requires authentication).
    • Response:
      {
        "users": [
          {
            "ID": 1,
            "CreatedAt": "2024-02-17T00:31:31.3624404+07:00",
            "UpdatedAt": "2024-02-17T00:31:31.3624404+07:00",
            "DeletedAt": null,
            "UserID": 1
          },
          {
            "ID": 2,
            "CreatedAt": "2024-02-17T00:31:31.3624404+07:00",
            "UpdatedAt": "2024-02-17T00:31:31.3624404+07:00",
            "DeletedAt": null,
            "UserID": 2
          }
        ]
      }
      
  • POST /api/v1/users

    • Description: Creates a new user (requires authentication).
    • Request:
      {
        "UserID": "1"
      }
      
    • Response:
      {
        "user": {
           "ID": 1,
           "CreatedAt": "2024-02-17T00:31:31.3624404+07:00",
           "UpdatedAt": "2024-02-17T00:31:31.3624404+07:00",
           "DeletedAt": null,
           "UserID": 1
        }
      }
      

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAPI

func InitAPI()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL