response

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdPropertyName    = "id"
	SubIdPropertyName = "subId"
)
View Source
const ZitiControllerVersionHeader = "ziti-version"

Variables

This section is empty.

Functions

func AddVersionHeader

func AddVersionHeader(rw http.ResponseWriter)

func Respond added in v0.14.35

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

func RespondWithApiError added in v0.14.35

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

func RespondWithError added in v0.14.35

func RespondWithError(w http.ResponseWriter, 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 Identifier

type Identifier interface {
	GetId() string
	GetSelfUrl() url.URL
}

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 *apierror.ApiError)
	SetProducer(producer runtime.Producer)
	GetProducer() runtime.Producer
	RespondWithCouldNotReadBody(err error)
	RespondWithCouldNotParseBody(err error)
	RespondWithValidationErrors(errors *schema.ValidationErrors)
	RespondWithNotFound()
	RespondWithNotFoundWithCause(cause error)
	RespondWithFieldError(fe *validation.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 *apierror.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 *validation.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)

type Response

type Response struct {
	Contents       interface{}
	HttpStatusCode int
}

func NewEntityResponse

func NewEntityResponse(contents interface{}, httpStatusCode int) (*Response, error)

func (*Response) Respond

func (r *Response) Respond(w http.ResponseWriter) error

Jump to

Keyboard shortcuts

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