response

package
v0.19.110 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdPropertyName    = "id"
	SubIdPropertyName = "subId"
)
View Source
const (
	ApiSessionExpirationSecondsHeader = "expiration-seconds"
	ApiSessionExpiresAtHeader         = "expires-at"
	ServerHeader                      = "server"
)

Variables

This section is empty.

Functions

func AddHeaders added in v0.17.56

func AddHeaders(rc *RequestContext)

func AddSessionHeaders added in v0.17.56

func AddSessionHeaders(rc *RequestContext)

func Respond added in v0.14.35

func Respond(w http.ResponseWriter, path, requestId string, producer runtime.Producer, data interface{}, httpStatus int)

func RespondWithApiError added in v0.14.35

func RespondWithApiError(w http.ResponseWriter, r *http.Request, requestId string, producer runtime.Producer, apiError *errorz.ApiError)

func RespondWithError added in v0.14.35

func RespondWithError(w http.ResponseWriter, r *http.Request, requestId string, producer runtime.Producer, err error)

Types

type EventLogger

type EventLogger interface {
	Log(actorType, actorId, eventType, entityType, entityId, formatString string, formatData []string, data map[interface{}]interface{})
}

type IdType

type IdType int

type RequestContext

type RequestContext struct {
	Responder
	Id                string
	ApiSession        *model.ApiSession
	Identity          *model.Identity
	ActivePermissions []string
	ResponseWriter    http.ResponseWriter
	Request           *http.Request
	EventLogger       EventLogger
	SessionToken      string

	Body []byte
	// contains filtered or unexported fields
}

func (*RequestContext) GetEntityId added in v0.14.35

func (rc *RequestContext) GetEntityId() (string, error)

func (*RequestContext) GetEntitySubId added in v0.14.35

func (rc *RequestContext) GetEntitySubId() (string, error)

func (*RequestContext) SetEntityId added in v0.14.35

func (rc *RequestContext) SetEntityId(id string)

func (*RequestContext) SetEntitySubId added in v0.14.35

func (rc *RequestContext) SetEntitySubId(id string)

type Responder

type Responder interface {
	Respond(data interface{}, httpStatus int)
	RespondWithOk(data interface{}, meta *rest_model.Meta)
	RespondWithEmptyOk()
	RespondWithError(err error)
	RespondWithApiError(apiError *errorz.ApiError)
	SetProducer(producer runtime.Producer)
	GetProducer() runtime.Producer
	RespondWithCouldNotReadBody(err error)
	RespondWithCouldNotParseBody(err error)
	RespondWithValidationErrors(errors *schema.ValidationErrors)
	RespondWithNotFound()
	RespondWithNotFoundWithCause(cause error)
	RespondWithFieldError(fe *errorz.FieldError)
	RespondWithCreatedId(id string, link rest_model.Link)
}

todo: rename to Responder, remove old Responder and RequestResponder

type ResponderImpl added in v0.14.35

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

func NewResponder added in v0.14.35

func NewResponder(rc *RequestContext) *ResponderImpl

func (*ResponderImpl) GetProducer added in v0.14.35

func (responder *ResponderImpl) GetProducer() runtime.Producer

func (*ResponderImpl) Respond added in v0.14.35

func (responder *ResponderImpl) Respond(data interface{}, httpStatus int)

func (*ResponderImpl) RespondWithApiError added in v0.14.35

func (responder *ResponderImpl) RespondWithApiError(apiError *errorz.ApiError)

func (*ResponderImpl) RespondWithCouldNotParseBody added in v0.14.35

func (responder *ResponderImpl) RespondWithCouldNotParseBody(err error)

func (*ResponderImpl) RespondWithCouldNotReadBody added in v0.14.35

func (responder *ResponderImpl) RespondWithCouldNotReadBody(err error)

func (*ResponderImpl) RespondWithCreatedId added in v0.14.35

func (responder *ResponderImpl) RespondWithCreatedId(id string, link rest_model.Link)

func (*ResponderImpl) RespondWithEmptyOk added in v0.14.35

func (responder *ResponderImpl) RespondWithEmptyOk()

func (*ResponderImpl) RespondWithError added in v0.14.35

func (responder *ResponderImpl) RespondWithError(err error)

func (*ResponderImpl) RespondWithFieldError added in v0.14.35

func (responder *ResponderImpl) RespondWithFieldError(fe *errorz.FieldError)

func (*ResponderImpl) RespondWithNotFound added in v0.14.35

func (responder *ResponderImpl) RespondWithNotFound()

func (*ResponderImpl) RespondWithNotFoundWithCause added in v0.14.35

func (responder *ResponderImpl) RespondWithNotFoundWithCause(cause error)

func (*ResponderImpl) RespondWithOk added in v0.14.35

func (responder *ResponderImpl) RespondWithOk(data interface{}, meta *rest_model.Meta)

func (*ResponderImpl) RespondWithValidationErrors added in v0.14.35

func (responder *ResponderImpl) RespondWithValidationErrors(errors *schema.ValidationErrors)

func (*ResponderImpl) SetProducer added in v0.14.35

func (responder *ResponderImpl) SetProducer(producer runtime.Producer)

Jump to

Keyboard shortcuts

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