rest

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(cfg APIConfig) (*API, error)

func (*API) GetHandler

func (a *API) GetHandler() http.Handler

type APIConfig

type APIConfig struct {
	PlayingService play.Service   `validate:"nonnil"`
	BattleService  battle.Service `validate:"nonnil"`
	IsWebEnabled   bool
}

func (APIConfig) Validate

func (c APIConfig) Validate() error

type Error

type Error struct {
	StatusCode int
	Err        string
	Message    string
}

func NewBadRequestError

func NewBadRequestError(msg string) *Error

func NewBattleNotFoundError

func NewBattleNotFoundError() *Error

func NewGameNotFoundError

func NewGameNotFoundError() *Error

func NewInternalServerError

func NewInternalServerError(msg string) *Error

func NewInvalidBattleStateError

func NewInvalidBattleStateError() *Error

func NewPartnerNotFoundError

func NewPartnerNotFoundError() *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

type RespBody

type RespBody struct {
	StatusCode int         `json:"-"`
	OK         bool        `json:"ok"`
	Data       interface{} `json:"data,omitempty"`
	Err        string      `json:"err,omitempty"`
	Message    string      `json:"msg,omitempty"`
	Timestamp  int64       `json:"ts"`
}

func NewErrorResp

func NewErrorResp(err error) *RespBody

func NewSuccessResp

func NewSuccessResp(data interface{}) *RespBody

func (*RespBody) Render

func (rb *RespBody) Render(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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