webapi

package
v0.0.0-...-f89b38e Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeaderXBackground    = "x-background"
	HTTPHeaderXBackgroundTTL = "x-background-ttl"
	DefaultTimeout           = 100 * time.Millisecond
)
View Source
const ErrMsgWritingResponse = "Error while writing response"
View Source
const TracerNameServer = "public-api"

Variables

This section is empty.

Functions

func AsyncMw

func AsyncMw(cacheConn *responsecache.Cache) func(http.Handler) http.Handler

func BadRequest

func BadRequest(ctx context.Context, writer http.ResponseWriter, msg string)

func CachedResponse

func CachedResponse(cacheConn *responsecache.Cache) http.HandlerFunc

func CreateRouter

func CreateRouter(logger logging.Logger, handler *Handler, cacheConn *responsecache.Cache) *chi.Mux

func InternalError

func InternalError(ctx context.Context, writer http.ResponseWriter, s string)

func LoggingMiddleware

func LoggingMiddleware(logger logging.Logger) func(http.Handler) http.Handler

func NewAsyncResponseWriter

func NewAsyncResponseWriter() *asyncResponseWriter

func NotFound

func NotFound(ctx context.Context, w http.ResponseWriter, msg string)

func StatusAccepted

func StatusAccepted(ctx context.Context, writer http.ResponseWriter, s, backgroundID string)

func StatusOk

func StatusOk(ctx context.Context, writer http.ResponseWriter, s string)

func TraceWrapRouter

func TraceWrapRouter(router *chi.Mux) http.Handler

func WithLogRequestBoundaries

func WithLogRequestBoundaries() func(next http.Handler) http.Handler

Types

type Handler

type Handler struct {
	UserClient    userPb.UsersClient
	UserTxClient  userTxPb.DistributedTxServiceClient
	OrderClient   orderPb.OrdersManagerServiceClient
	OrderTxClient orderPb.TnxConfirmingServiceClient
}

func NewHandler

func NewHandler(userConn *grpc.ClientConn, orderConn *grpc.ClientConn) *Handler

func (*Handler) SendMessage

func (h *Handler) SendMessage(writer http.ResponseWriter, request *http.Request)

SendMessage godoc @Summary Send message @Description Put message with name and label to DB by 2pc transactions @Tags accounts @Accept json @Produce json @Param message body Message true "Message" @Success 200 {string} string "ok" @Failure 400 {string} string "message decode error" @Failure 500 {string} string "server error" @Router /send [post].

type Message

type Message struct {
	Name  string `json:"name" example:"John"`
	Label string `json:"label" example:"Bag"`
}

Jump to

Keyboard shortcuts

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