handlers

package
v0.0.0-...-a455c07 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadParams = &ErrResponse{HTTPStatusCode: 400, StatusText: "Bad request."}
View Source
var ErrInternalServer = &ErrResponse{HTTPStatusCode: 500, StatusText: "Internal server error."}
View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct{}

func NewAuthHandler

func NewAuthHandler() *AuthHandler

func (*AuthHandler) Login

func (a *AuthHandler) Login(w http.ResponseWriter, r *http.Request)

func (*AuthHandler) Logout

func (a *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)

func (*AuthHandler) Register

func (a *AuthHandler) Register(w http.ResponseWriter, r *http.Request)

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type Handlers

type Handlers struct {
	AuthHandler IAuthHandler
	UserHandler IUserHandler
}

func NewHandlers

func NewHandlers(services *services.Services) *Handlers

type IAuthHandler

type IAuthHandler interface {
	Login(http.ResponseWriter, *http.Request)
	Register(http.ResponseWriter, *http.Request)
	Logout(http.ResponseWriter, *http.Request)
}

type IUserHandler

type IUserHandler interface {
	GetAll(http.ResponseWriter, *http.Request)
	GetByID(http.ResponseWriter, *http.Request)
}

type UserHandler

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

func NewUserHandler

func NewUserHandler(userService services.IUserService) *UserHandler

func (*UserHandler) GetAll

func (a *UserHandler) GetAll(w http.ResponseWriter, r *http.Request)

func (*UserHandler) GetByID

func (a *UserHandler) GetByID(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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