httpbody

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_httpbody_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type HttpBody

type HttpBody struct {

	// The HTTP Content-Type header value specifying the content type of the body.
	ContentType string `protobuf:"bytes,1,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	// The HTTP request/response body as raw binary.
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// Application specific response metadata. Must be set in the first response
	// for streaming APIs.
	Extensions []*anypb.Any `protobuf:"bytes,3,rep,name=extensions,proto3" json:"extensions,omitempty"`
	// contains filtered or unexported fields
}

Message that represents an arbitrary HTTP body. It should only be used for payload formats that can't be represented as JSON, such as raw binary or an HTML page.

This message can be used both in streaming and non-streaming API methods in the request as well as the response.

It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body.

Example:

message GetResourceRequest {
  // A unique request id.
  string request_id = 1;

  // The raw HTTP body is bound to this field.
  google.api.HttpBody http_body = 2;
}

service ResourceService {
  rpc GetResource(GetResourceRequest) returns (google.api.HttpBody);
  rpc UpdateResource(google.api.HttpBody) returns
  (google.protobuf.Empty);
}

Example with streaming methods:

service CaldavService {
  rpc GetCalendar(stream google.api.HttpBody)
    returns (stream google.api.HttpBody);
  rpc UpdateCalendar(stream google.api.HttpBody)
    returns (stream google.api.HttpBody);
}

Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.

func (*HttpBody) Descriptor deprecated

func (*HttpBody) Descriptor() ([]byte, []int)

Deprecated: Use HttpBody.ProtoReflect.Descriptor instead.

func (*HttpBody) GetContentType

func (x *HttpBody) GetContentType() string

func (*HttpBody) GetData

func (x *HttpBody) GetData() []byte

func (*HttpBody) GetExtensions

func (x *HttpBody) GetExtensions() []*anypb.Any

func (*HttpBody) ProtoMessage

func (*HttpBody) ProtoMessage()

func (*HttpBody) ProtoReflect

func (x *HttpBody) ProtoReflect() protoreflect.Message

func (*HttpBody) Reset

func (x *HttpBody) Reset()

func (*HttpBody) String

func (x *HttpBody) String() string

func (*HttpBody) Validate

func (m *HttpBody) Validate() error

Validate checks the field values on HttpBody with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*HttpBody) ValidateAll

func (m *HttpBody) ValidateAll() error

ValidateAll checks the field values on HttpBody with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HttpBodyMultiError, or nil if none found.

type HttpBodyMultiError

type HttpBodyMultiError []error

HttpBodyMultiError is an error wrapping multiple validation errors returned by HttpBody.ValidateAll() if the designated constraints aren't met.

func (HttpBodyMultiError) AllErrors

func (m HttpBodyMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (HttpBodyMultiError) Error

func (m HttpBodyMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type HttpBodyValidationError

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

HttpBodyValidationError is the validation error returned by HttpBody.Validate if the designated constraints aren't met.

func (HttpBodyValidationError) Cause

func (e HttpBodyValidationError) Cause() error

Cause function returns cause value.

func (HttpBodyValidationError) Error

func (e HttpBodyValidationError) Error() string

Error satisfies the builtin error interface

func (HttpBodyValidationError) ErrorName

func (e HttpBodyValidationError) ErrorName() string

ErrorName returns error name.

func (HttpBodyValidationError) Field

func (e HttpBodyValidationError) Field() string

Field function returns field value.

func (HttpBodyValidationError) Key

func (e HttpBodyValidationError) Key() bool

Key function returns key value.

func (HttpBodyValidationError) Reason

func (e HttpBodyValidationError) Reason() string

Reason function returns reason value.

Jump to

Keyboard shortcuts

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