session

package
v0.0.0-...-76fc54f Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type I

type I interface {
	GetSession(c *gin.Context)
	PostSession(c *gin.Context)
	DelSession(c *gin.Context)
}

I is interface of authentication.

type Options

type Options struct {
	Env           env.Environments
	VaccineClient *vaccineclient.VaccineClient
}

Options provides interface to change behavior of User.

type PostSessionRequest

type PostSessionRequest struct {
	// in: body
	// required: true
	Body *PostSessionRequestModel `json:"body"`
}

PostSessionRequest is the request of PostSession.

swagger:parameters PostSessionRequest

type PostSessionRequestModel

type PostSessionRequestModel struct {
	// The user's nationID
	// example: A123456789
	// required: true
	NationID string `json:"nationID" binding:"required"`
	// The user's healthCardID
	// example: 000011112222
	// required: true
	HealthCardID string `json:"healthCardID" binding:"required"`
}

PostSessionRequestModel is the body format of PostSessionRequest.

swagger:model PostSessionRequestModel

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session handles all

func New

func New(opt Options) *Session

New returns default instance of Session.

func (*Session) DelSession

func (s *Session) DelSession(c *gin.Context)

DelSession deletes the session. swagger:route DELETE /api/session Session DelSession

Logout the user.

Responses:

204: NoContentResponse

func (*Session) GetSession

func (s *Session) GetSession(c *gin.Context)

GetSession returns the user information. swagger:route GET /api/session Session GetSession

Get the user information.

Responses:

200: UserResponse
400: BadRequestErrorResponse
401: UnauthorizedErrorResponse
404: NotFoundErrorResponse
500: InternalServerErrorResponse

func (*Session) PostSession

func (s *Session) PostSession(c *gin.Context)

PostSession lets user login. swagger:route POST /api/sessions Session PostSessionRequest

Login.

Responses:

200: SessionResponse
400: BadRequestErrorResponse
500: InternalServerErrorResponse

type SessionResponse

type SessionResponse struct {
	// The session info
	// in: body
	User *models.UserModel `json:"user"`
}

SessionResponse is the response of GetSession/PostSession.

swaggger: response SessionResponse

Jump to

Keyboard shortcuts

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