handler

package
v0.0.0-...-54d6317 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomHTTPError

func CustomHTTPError(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, _ *http.Request, err error)

CustomHTTPError for stripping error contents back

Types

type Database

type Database interface {
	GetPetByID(ctx context.Context, id int64) (*pb.Pet, error)
	UpdatePetWithForm(ctx context.Context, id int64, name string, status string) error
	DeletePet(ctx context.Context, id int64) error
	UploadFile(ctx context.Context, id int64, url string) error
	AddPet(ctx context.Context, pet *pb.Pet) error
	UpdatePet(ctx context.Context, pet *pb.Pet) error
	FindPetsByStatus(ctx context.Context, statuses []string) (*pb.Pets, error)
}

Database defines the set of methods that the petstore server needs to be able to treat any object as a database

type PetstoreServer

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

PetstoreServer implements the RPC and REST server

func NewPetstoreServer

func NewPetstoreServer(log *logrus.Logger, db Database, rcpPort, restPort int, apiKey string) *PetstoreServer

NewPetstoreServer returns a new PetstoreServer

func (*PetstoreServer) AddPet

func (s *PetstoreServer) AddPet(ctx context.Context, req *pb.Pet) (*pb.Pet, error)

AddPet adds a pet to the store

func (*PetstoreServer) DeletePet

func (s *PetstoreServer) DeletePet(ctx context.Context, req *pb.PetID) (*pb.Empty, error)

DeletePet removes a pet. Check the req header for the API_KEY value

func (*PetstoreServer) FindPetsByStatus

func (s *PetstoreServer) FindPetsByStatus(ctx context.Context, req *pb.StatusReq) (*pb.Pets, error)

FindPetsByStatus gets all the pets that match any of the passed in statuses

func (*PetstoreServer) GetPetByID

func (s *PetstoreServer) GetPetByID(ctx context.Context, req *pb.PetID) (*pb.Pet, error)

GetPetByID implements PetstoreService rpc

func (*PetstoreServer) Run

func (s *PetstoreServer) Run()

Run starts and runs the server

func (*PetstoreServer) UpdatePet

func (s *PetstoreServer) UpdatePet(ctx context.Context, req *pb.Pet) (*pb.Pet, error)

UpdatePet updates a pet from the input data

func (*PetstoreServer) UpdatePetWithForm

func (s *PetstoreServer) UpdatePetWithForm(ctx context.Context, req *pb.UpdatePetWithFormReq) (*pb.Empty, error)

UpdatePetWithForm updates the name and status of a Pet using form encoded data, converted to protobuf

func (*PetstoreServer) UploadFile

func (s *PetstoreServer) UploadFile(ctx context.Context, req *pb.UploadFileReq) (*pb.ApiResponse, error)

UploadFile uploads a photo against a pet

Jump to

Keyboard shortcuts

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