api

package
v0.0.0-...-0de1ee4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalServer   = &ErrorResponse{StatusCode: http.StatusInternalServerError, ErrorText: "internal server error"}
	ErrUnauthorized     = &ErrorResponse{StatusCode: http.StatusUnauthorized, ErrorText: "unauthorized"}
	ErrDecodeJsonFailed = &ErrorResponse{StatusCode: http.StatusBadRequest, ErrorText: "failed to decode JSON"}
)
View Source
var DefaultSet = wire.NewSet(
	ProvideRoutes,
	New,
)

Functions

This section is empty.

Types

type Api

type Api struct {
	chi.Router
}

func New

func New(routes ...Route) *Api

type ErrorResponse

type ErrorResponse struct {
	Err        error  `json:"-"`
	StatusCode int    `json:"-"`
	ErrorText  string `json:"error"`
}

func ErrExecute

func ErrExecute(err error) *ErrorResponse

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

func (*ErrorResponse) Render

func (*ErrorResponse) WithError

func (e *ErrorResponse) WithError(err error) *ErrorResponse

type GetMe

type GetMe struct {
}

func NewGetMe

func NewGetMe() *GetMe

func (*GetMe) Method

func (g *GetMe) Method() string

func (*GetMe) Path

func (g *GetMe) Path() string

func (*GetMe) ServeHTTP

func (g *GetMe) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GetMeResponse

type GetMeResponse struct {
	Id string `json:"id"`
}

type PostMatch

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

func NewPostMatch

func NewPostMatch(createMatch *usecase.CreateMatchCommand) *PostMatch

func (*PostMatch) Method

func (p *PostMatch) Method() string

func (*PostMatch) Path

func (p *PostMatch) Path() string

func (*PostMatch) ServeHTTP

func (p *PostMatch) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PostMatchInput

type PostMatchInput struct {
	Team string `json:"team"`
}

type PostMatchOutput

type PostMatchOutput struct {
	MatchId string `json:"match_id"`
}

type Route

type Route interface {
	Method() string
	Path() string
	http.Handler
}

func ProvideRoutes

func ProvideRoutes(
	createMatchCommand *usecase.CreateMatchCommand,
) []Route

Jump to

Keyboard shortcuts

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