app

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTraceId      = "tx.traceId"
	LogSpanId       = "tx.spanId"
	LogParentSpanId = "tx.parentSpanId"
	LogChildSpanId  = "tx.childSpanId"
	LogTenantId     = "gears.app.id"
)

Logging expected keys

View Source
const (
	HeaderTraceId      = "X-B3-TraceId"
	HeaderSpanId       = "X-B3-SpanId"
	HeaderParentSpanId = "X-B3-ParentSpanId"
	HeaderTenantId     = "Application-Id"
)

API header expected keys

Variables

This section is empty.

Functions

func NewMiddleware

func NewMiddleware(logger *zerolog.Logger) []func(next http.Handler) http.Handler

func NewMux

func NewMux(a *APIManager, middleware []func(next http.Handler) http.Handler) (http.Handler, error)

func ProvideLogger added in v0.2.0

func ProvideLogger(config config.Config) (*zerolog.Logger, error)

func SetupAPIServer

func SetupAPIServer(lifecycle fx.Lifecycle, config config.Config, logger *zerolog.Logger, mux http.Handler) error

Types

type APIManager

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

func NewAPIManager

func NewAPIManager(routingMgr tablemgr.RoutingTableManager, tenantStorer tenant.TenantStorer, quotaManager *quota.QuotaManager) (*APIManager, error)

type ApiError added in v0.2.0

type ApiError interface {
	error
	StatusCode() int
}

Rest API errors

type BadRequestError added in v0.2.0

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

func (*BadRequestError) Error added in v0.2.0

func (e *BadRequestError) Error() string

func (*BadRequestError) StatusCode added in v0.2.0

func (e *BadRequestError) StatusCode() int

type InternalServerError added in v0.2.0

type InternalServerError struct {
	Wrapped error
}

func (*InternalServerError) Error added in v0.2.0

func (e *InternalServerError) Error() string

func (*InternalServerError) StatusCode added in v0.2.0

func (e *InternalServerError) StatusCode() int

type InvalidOptionError

type InvalidOptionError struct {
	Option string
}

InvalidOptionError is returned when an invalid option is passed in

func (*InvalidOptionError) Error

func (e *InvalidOptionError) Error() string

type NotFoundError added in v0.2.0

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

func (*NotFoundError) Error added in v0.2.0

func (e *NotFoundError) Error() string

func (*NotFoundError) StatusCode added in v0.2.0

func (e *NotFoundError) StatusCode() int

type NotImplementedError added in v0.2.0

type NotImplementedError struct {
}

func (*NotImplementedError) Error added in v0.2.0

func (e *NotImplementedError) Error() string

func (*NotImplementedError) StatusCode added in v0.2.0

func (e *NotImplementedError) StatusCode() int

type Response

type Response struct {
	Status  *Status  `json:"status,omitempty" xml:"status,omitempty"`
	Tracing *Tracing `json:"tx,omitempty" xml:"tx,omitempty"`

	Item  interface{} `json:"item,omitempty" xml:"item,omitempty"`
	Items interface{} `json:"items,omitempty" xml:"items,omitempty"`
	Data  interface{} `json:"data,omitempty" xml:"data,omitempty"`
}

func ErrorResponse added in v0.2.0

func ErrorResponse(apiErr ApiError) Response

func ItemResponse added in v0.2.0

func ItemResponse(item interface{}) Response

func ItemsResponse added in v0.2.0

func ItemsResponse(item interface{}) Response

func SimpleResponse added in v0.2.0

func SimpleResponse(ctx context.Context) Response

func (Response) Respond

func (r Response) Respond(ctx context.Context, w http.ResponseWriter)

type Status

type Status struct {
	Code    int    `json:"code,omitempty" xml:"code,omitempty"`
	Message string `json:"message,omitempty" xml:"message,omitempty"`
}

type Tenant added in v0.2.0

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

func NewTenantId added in v0.2.0

func NewTenantId(orgId, appId string) *Tenant

func (*Tenant) AppId added in v0.2.0

func (t *Tenant) AppId() string

func (*Tenant) OrgId added in v0.2.0

func (t *Tenant) OrgId() string

type Tracing

type Tracing struct {
	TraceId string `json:"traceId,omitempty" xml:"traceId,omitempty"`
	SpanId  string `json:"spanId,omitempty" xml:"spanId,omitempty"`
}

Directories

Path Synopsis
Package classification EARS Documentation EARS API Schemes: http https BasePath: / Version: 1.0.0 Host: ears.comcast.com Consumes: - application/json Produces: - application/json Security: - basic SecurityDefinitions: basic: type: basic swagger:meta
Package classification EARS Documentation EARS API Schemes: http https BasePath: / Version: 1.0.0 Host: ears.comcast.com Consumes: - application/json Produces: - application/json Security: - basic SecurityDefinitions: basic: type: basic swagger:meta

Jump to

Keyboard shortcuts

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