api

package
v0.0.0-...-72c8848 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyUsername = errors.New("empty username")
	ErrEmptyAvatar   = errors.New("empty avatar")
)

Functions

func MakeCreateUserHandle

func MakeCreateUserHandle(svc UserService) func(c *gin.Context)

func MakeGetUserHandle

func MakeGetUserHandle(svc UserService) func(c *gin.Context)

func RegisterHTTPServer

func RegisterHTTPServer(r *gin.Engine, svc UserService)

Types

type CreateUserReply

type CreateUserReply struct {
	UID int `json:"uid"`
}

type CreateUserReq

type CreateUserReq struct {
	Username  string `json:"username"`
	AvatarURL string `json:"avatar"`
}

type GetUserReply

type GetUserReply struct {
	UID    int    `json:"uid"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

type GetUserReq

type GetUserReq struct {
	UID int `json:"uid"`
}

type UserService

type UserService interface {
	CreateUser(ctx context.Context, req *CreateUserReq) (*CreateUserReply, error)
	GetUser(ctx context.Context, req *GetUserReq) (*GetUserReply, error)
}

UserService is a service for user. It should be implemented by the business logic layer. Inject it into the API layer.

Jump to

Keyboard shortcuts

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