Documentation
¶
Index ¶
- Constants
- func AddVersionHeader(rw http.ResponseWriter)
- func RespondWithCreated(data interface{}, meta *Meta, link *Link, rc *RequestContext)
- func RespondWithOk(data interface{}, meta *Meta, rc *RequestContext)
- func RespondWithSimpleCreated(id string, link *Link, rc *RequestContext)
- type ApiResponseBody
- type ErrorResponse
- type EventLogger
- type IdType
- type Identifier
- type Link
- type Links
- type Meta
- type RequestContext
- type RequestResponder
- type RequestResponderFactory
- type RequestResponderImpl
- func (rr *RequestResponderImpl) RespondWithApiError(apiError *apierror.ApiError)
- func (rr *RequestResponderImpl) RespondWithCouldNotParseBody(e error)
- func (rr *RequestResponderImpl) RespondWithCouldNotReadBody(e error)
- func (rr *RequestResponderImpl) RespondWithCreated(data interface{}, meta *Meta, link *Link)
- func (rr *RequestResponderImpl) RespondWithCreatedId(id string, link *Link)
- func (rr *RequestResponderImpl) RespondWithError(e error)
- func (rr *RequestResponderImpl) RespondWithFieldError(err *validation.FieldError)
- func (rr *RequestResponderImpl) RespondWithMethodNotAllowed()
- func (rr *RequestResponderImpl) RespondWithNotFound()
- func (rr *RequestResponderImpl) RespondWithOk(data interface{}, meta *Meta)
- func (rr *RequestResponderImpl) RespondWithUnauthorizedError(*RequestContext)
- func (rr *RequestResponderImpl) RespondWithValidationErrors(e *schema.ValidationErrors)
- type Responder
- type Response
Constants ¶
View Source
const ( IdTypeString IdType = iota IdTypeUuid IdPropertyName = "id" SubIdPropertyName = "subId" )
View Source
const ZitiControllerVersionHeader = "ziti-version"
Variables ¶
This section is empty.
Functions ¶
func AddVersionHeader ¶
func AddVersionHeader(rw http.ResponseWriter)
func RespondWithCreated ¶
func RespondWithCreated(data interface{}, meta *Meta, link *Link, rc *RequestContext)
func RespondWithOk ¶
func RespondWithOk(data interface{}, meta *Meta, rc *RequestContext)
func RespondWithSimpleCreated ¶
func RespondWithSimpleCreated(id string, link *Link, rc *RequestContext)
Types ¶
type ApiResponseBody ¶
type ApiResponseBody struct {
Meta *Meta `json:"meta"`
Data interface{} `json:"data"`
}
func NewApiResponseBody ¶
func NewApiResponseBody(data interface{}, meta *Meta) *ApiResponseBody
type ErrorResponse ¶
func NewErrorResponse ¶
func NewErrorResponse(apiErr *apierror.ApiError, args map[string]interface{}) (*ErrorResponse, error)
func (*ErrorResponse) Respond ¶
func (er *ErrorResponse) Respond(rc *RequestContext) error
type EventLogger ¶
type Identifier ¶
type Link ¶
type RequestContext ¶
type RequestContext struct {
Id uuid.UUID
ApiSession *model.ApiSession
Identity *model.Identity
ActivePermissions []string
ResponseWriter http.ResponseWriter
Request *http.Request
RequestResponder RequestResponder
EventLogger EventLogger
}
func (*RequestContext) GetIdFromRequest ¶
func (rc *RequestContext) GetIdFromRequest(idType IdType) (string, error)
func (*RequestContext) GetSubIdFromRequest ¶
func (rc *RequestContext) GetSubIdFromRequest() (string, error)
type RequestResponder ¶
type RequestResponder interface {
RespondWithFieldError(err *validation.FieldError)
RespondWithApiError(apiError *apierror.ApiError)
RespondWithCouldNotParseBody(e error)
RespondWithCouldNotReadBody(e error)
RespondWithCreatedId(id string, link *Link)
RespondWithCreated(data interface{}, meta *Meta, link *Link)
RespondWithError(e error)
RespondWithNotFound()
RespondWithOk(data interface{}, meta *Meta)
RespondWithValidationErrors(ves *schema.ValidationErrors)
RespondWithMethodNotAllowed()
}
func NewRequestResponder ¶
func NewRequestResponder(rc *RequestContext) RequestResponder
type RequestResponderFactory ¶
type RequestResponderFactory func(rc *RequestContext) RequestResponder
type RequestResponderImpl ¶
type RequestResponderImpl struct {
// contains filtered or unexported fields
}
func (*RequestResponderImpl) RespondWithApiError ¶
func (rr *RequestResponderImpl) RespondWithApiError(apiError *apierror.ApiError)
func (*RequestResponderImpl) RespondWithCouldNotParseBody ¶
func (rr *RequestResponderImpl) RespondWithCouldNotParseBody(e error)
func (*RequestResponderImpl) RespondWithCouldNotReadBody ¶
func (rr *RequestResponderImpl) RespondWithCouldNotReadBody(e error)
func (*RequestResponderImpl) RespondWithCreated ¶
func (rr *RequestResponderImpl) RespondWithCreated(data interface{}, meta *Meta, link *Link)
func (*RequestResponderImpl) RespondWithCreatedId ¶
func (rr *RequestResponderImpl) RespondWithCreatedId(id string, link *Link)
func (*RequestResponderImpl) RespondWithError ¶
func (rr *RequestResponderImpl) RespondWithError(e error)
func (*RequestResponderImpl) RespondWithFieldError ¶
func (rr *RequestResponderImpl) RespondWithFieldError(err *validation.FieldError)
func (*RequestResponderImpl) RespondWithMethodNotAllowed ¶ added in v0.9.6
func (rr *RequestResponderImpl) RespondWithMethodNotAllowed()
func (*RequestResponderImpl) RespondWithNotFound ¶
func (rr *RequestResponderImpl) RespondWithNotFound()
func (*RequestResponderImpl) RespondWithOk ¶
func (rr *RequestResponderImpl) RespondWithOk(data interface{}, meta *Meta)
func (*RequestResponderImpl) RespondWithUnauthorizedError ¶
func (rr *RequestResponderImpl) RespondWithUnauthorizedError(*RequestContext)
func (*RequestResponderImpl) RespondWithValidationErrors ¶
func (rr *RequestResponderImpl) RespondWithValidationErrors(e *schema.ValidationErrors)
type Responder ¶
type Responder interface {
Respond(rc *RequestContext) error
}
type Response ¶
type Response struct {
Contents interface{}
HttpStatusCode int
}
func NewApiEntityResponder ¶
func NewEntityResponse ¶
Click to show internal directories.
Click to hide internal directories.