server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func NewUserFilter

func NewUserFilter(r *http.Request) (user.Filter, error)

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

func TranslateUser

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

TranslateUser translates an user user to a network user.

func TranslateUserRequest

func TranslateUserRequest(u rest.UserRequest) (user.Change, error)

TranslateUserRequest translates a network user user request to an user user request.

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)
	Remove(context.Context, user.ID) error
}

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

type UsersService

type UsersService struct {
	Storage UserStorage
}

UserService services user related network requests.

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

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)

Remove handles a request to remove an user.

func (UsersService) Shutdown

func (UsersService) Shutdown()

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)

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