server

package
v0.2.5 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: 16 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 Handler added in v0.2.2

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux added in v0.2.2

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 added in v0.2.2

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

func HandlerWithOptions added in v0.2.2

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

HandlerWithOptions creates http.Handler with additional options

func NewNewUserFilter added in v0.2.2

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

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

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 TranslateUserCreateRequest added in v0.2.5

func TranslateUserCreateRequest(r UserCreateRequest) (user.Change, error)

TranslateUserCreateRequest translates a user create request to an user change.

func TranslateUserRequest

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

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

func TranslateUserUpdateRequest added in v0.2.5

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

TranslateUserUpdateRequest translates a user create request to an user change.

Types

type CreateJSONRequestBody added in v0.2.4

type CreateJSONRequestBody = UserCreateRequest

CreateJSONRequestBody defines body for Create for application/json ContentType.

type GorillaServerOptions added in v0.2.2

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

type InvalidParamFormatError added in v0.2.2

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error added in v0.2.2

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap added in v0.2.2

func (e *InvalidParamFormatError) Unwrap() error

type ListParams added in v0.2.2

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 added in v0.2.2

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError added in v0.2.2

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error added in v0.2.2

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap added in v0.2.2

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError added in v0.2.2

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error added in v0.2.2

func (e *RequiredParamError) Error() string

type ServerInterface added in v0.2.2

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)
	// Get returns a user.
	// (GET /v1/user/{id})
	Get(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 added in v0.2.2

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

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Create added in v0.2.4

Create operation middleware

func (*ServerInterfaceWrapper) Get added in v0.2.3

Get operation middleware

func (*ServerInterfaceWrapper) List added in v0.2.2

List operation middleware

func (*ServerInterfaceWrapper) Update added in v0.2.5

Update operation middleware

type TooManyValuesForParamError added in v0.2.2

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error added in v0.2.2

type UnescapedCookieParamError added in v0.2.2

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error added in v0.2.2

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap added in v0.2.2

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError added in v0.2.2

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error added in v0.2.2

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap added in v0.2.2

func (e *UnmarshalingParamError) Unwrap() error

type UpdateJSONRequestBody added in v0.2.5

type UpdateJSONRequestBody = UserUpdateRequest

UpdateJSONRequestBody defines body for Update for application/json ContentType.

type User added in v0.2.2

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 NewTranslateUser added in v0.2.2

func NewTranslateUser(u *user.User) User

NewTranslateUser translates an user user to a network user.

type UserCreateRequest added in v0.2.4

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

UserCreateRequest UserCreateRequest is used to request a user be created.

type UserResponse added in v0.2.3

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

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

type UserUpdateRequest added in v0.2.5

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

UserUpdateRequest UserUpdateRequest is used to request a user be updated.

type UsersResponse added in v0.2.2

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

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