server

package
v0.2.7 Latest Latest
Warning

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

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

Documentation

Overview

Package server provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT.

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 UserCreateRequest) (user.Change, error)

CreateChange translates a user create request to an user change.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r *mux.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r *mux.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options GorillaServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func UpdateChange added in v0.2.7

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

UpdateChange translates a user create request to an user change.

func UserFilter added in v0.2.7

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

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

Types

type AssociatePlayerJSONRequestBody added in v0.2.7

type AssociatePlayerJSONRequestBody = AssociatePlayerRequest

AssociatePlayerJSONRequestBody defines body for AssociatePlayer for application/json ContentType.

type AssociatePlayerRequest added in v0.2.7

type AssociatePlayerRequest struct {
	PlayerID string `json:"playerID"`
}

AssociatePlayerRequest AssociatePlayerRequest is used to associate a player to the user.

type CreateJSONRequestBody

type CreateJSONRequestBody = UserCreateRequest

CreateJSONRequestBody defines body for Create for application/json ContentType.

type GorillaServerOptions

type GorillaServerOptions struct {
	BaseURL          string
	BaseRouter       *mux.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type ListParams

type ListParams struct {
	// Offset An offset into the total list of users.
	Offset *string `form:"offset,omitempty" json:"offset,omitempty"`

	// Limit An limit to the number of users returned.
	Limit *string `form:"limit,omitempty" json:"limit,omitempty"`
}

ListParams defines parameters for List.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServerInterface

type ServerInterface interface {
	// List returns a list of users.
	// (GET /v1/user)
	List(w http.ResponseWriter, r *http.Request, params ListParams)
	// Create creates a user.
	// (POST /v1/user)
	Create(w http.ResponseWriter, r *http.Request)
	// Remove removes a user.
	// (DELETE /v1/user/{id})
	Remove(w http.ResponseWriter, r *http.Request, id string)
	// Get returns a user.
	// (GET /v1/user/{id})
	Get(w http.ResponseWriter, r *http.Request, id string)
	// Associates a player with a user.
	// (PATCH /v1/user/{id})
	AssociatePlayer(w http.ResponseWriter, r *http.Request, id string)
	// Update updates a user.
	// (PUT /v1/user/{id})
	Update(w http.ResponseWriter, r *http.Request, id string)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) AssociatePlayer added in v0.2.7

func (siw *ServerInterfaceWrapper) AssociatePlayer(w http.ResponseWriter, r *http.Request)

AssociatePlayer operation middleware

func (*ServerInterfaceWrapper) Create

Create operation middleware

func (*ServerInterfaceWrapper) Get

Get operation middleware

func (*ServerInterfaceWrapper) List

List operation middleware

func (*ServerInterfaceWrapper) Remove

Remove operation middleware

func (*ServerInterfaceWrapper) Update

Update operation middleware

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateJSONRequestBody

type UpdateJSONRequestBody = UserUpdateRequest

UpdateJSONRequestBody defines body for Update for application/json ContentType.

type User

type User struct {
	ID        string           `json:"id"`
	Login     string           `json:"login"`
	PublicKey string           `json:"publicKey"`
	PlayerID  string           `json:"playerID"`
	Created   arcade.Timestamp `json:"created"`
	Updated   arcade.Timestamp `json:"updated"`
}

User holds a user's information, and is sent in a response.

func TranslateUser

func TranslateUser(u *user.User) User

TranslateUser translates an user user to a network user.

type UserCreateRequest

type UserCreateRequest struct {
	Login     string `json:"login"`
	PublicKey string `json:"publicKey"`
}

UserCreateRequest UserCreateRequest is used to request a user be created.

type UserResponse

type UserResponse struct {
	// User holds a user's information, and is sent in a response.
	User User `json:"user"`
}

UserResponse returns a single user in the response.

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 UserUpdateRequest

type UserUpdateRequest struct {
	Login     string `json:"login"`
	PublicKey string `json:"publicKey"`
}

UserUpdateRequest UserUpdateRequest is used to request a user be updated.

type UsersResponse

type UsersResponse struct {
	Users []User `json:"users"`
}

UsersResponse returns a multiple users.

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)

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 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()

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