server

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	V1UserRoute string = "/v1/user"
)

Variables

This section is empty.

Functions

func AssocPlayer added in v0.2.7

AssocPlayer translates a user player update request to an user change.

func CreateChange added in v0.2.7

func CreateChange(r oapi.UserCreateRequest) (user.Change, error)

CreateChange translates a user create request to an user change.

func TranslateUser

func TranslateUser(u *user.User) oapi.User

TranslateUser translates an user user to a network user.

func UpdateChange added in v0.2.7

func UpdateChange(r oapi.UserUpdateRequest) (user.Change, error)

UpdateChange translates a user create request to an user change.

func UserFilter added in v0.2.7

func UserFilter(params oapi.ListParams) (user.Filter, error)

UserFilter creates an user users filter from the the given request's query parameters.

Types

type UserStorage

type UserStorage interface {
	List(context.Context, user.Filter) ([]*user.User, error)
	Get(context.Context, user.ID) (*user.User, error)
	Create(context.Context, user.Create) (*user.User, error)
	Update(context.Context, user.ID, user.Update) (*user.User, error)
	AssociatePlayer(context.Context, user.ID, user.AssociatePlayer) (*user.User, error)
	Remove(context.Context, user.ID) error
}

UserStorage defines the expected behavior of the user manager in the data layer.

type UsersService

type UsersService struct {
	Storage UserStorage
}

UserService services user related network requests.

func (UsersService) AssociatePlayer added in v0.2.7

func (s UsersService) AssociatePlayer(w http.ResponseWriter, r *http.Request, id string)

AssociatePlayer associates a player with the given user.

func (UsersService) Create

func (s UsersService) Create(w http.ResponseWriter, r *http.Request)

Create handles a request to create an user.

func (UsersService) Get

Get handles a request to retrieve an user.

func (UsersService) List

func (s UsersService) List(w http.ResponseWriter, r *http.Request, params oapi.ListParams)

List handles a request to retrieve multiple users.

func (UsersService) Name

func (UsersService) Name() string

Name returns the name of the service.

func (UsersService) Register

func (s UsersService) Register(router *mux.Router)

Register sets up the http handler for this service with the given router.

func (UsersService) Remove

func (s UsersService) Remove(w http.ResponseWriter, r *http.Request, id string)

Remove handles a request to remove an user.

func (UsersService) Shutdown

func (UsersService) Shutdown(context.Context)

Shutdown is a no-op since there no long running processes for this service.

func (UsersService) Update

func (s UsersService) Update(w http.ResponseWriter, r *http.Request, id string)

Update handles a request to update an user.

Jump to

Keyboard shortcuts

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