gogrpc

package module
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: GPL-3.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// AuthorizationMetadataKey is the key used for authorization in metadata.
	AuthorizationMetadataKey = "authorization"

	// AuthorizationMetadataIndex is the index used for authorization in metadata.
	AuthorizationMetadataIndex = 0

	// RefreshTokenMetadataKey is the key used for refresh token in metadata.
	RefreshTokenMetadataKey = "x-refresh-token"

	// AccessTokenMetadataKey is the key used for access token in metadata.
	AccessTokenMetadataKey = "x-access-token"

	// GCloudAuthorizationMetadataKey is the key of the authorization metadata
	GCloudAuthorizationMetadataKey = "x-serverless-authorization"
)

Variables

View Source
var (
	ErrNilInterceptions = errors.New("grpc interceptions map cannot be nil")
)
View Source
var (
	InternalServerError = http.StatusText(http.StatusInternalServerError)
)

Functions

This section is empty.

Types

type DefaultErrorDetailsGenerator added in v0.4.3

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

DefaultErrorDetailsGenerator is the default implementation of ErrorDetailsGenerator

func NewDefaultErrorDetailsGenerator added in v0.4.3

func NewDefaultErrorDetailsGenerator(logger *slog.Logger) *DefaultErrorDetailsGenerator

NewDefaultErrorDetailsGenerator creates a new DefaultErrorDetailsGenerator

Parameters:

  • logger: the logger (optional, can be nil)

Returns:

  • *DefaultErrorDetailsGenerator: the created DefaultErrorDetailsGenerator

func (DefaultErrorDetailsGenerator) NewBadRequest added in v0.4.3

NewBadRequest creates a new bad request with the given field violations

Parameters:

  • violations: the field violations

Returns:

  • *errdetails.BadRequest: the created bad request

func (DefaultErrorDetailsGenerator) NewFieldViolation added in v0.4.3

func (d DefaultErrorDetailsGenerator) NewFieldViolation(
	field, description string,
) *errdetails.BadRequest_FieldViolation

NewFieldViolation creates a new field violation

Parameters:

  • field: the field that caused the violation
  • description: a description of the violation

Returns:

  • *errdetails.BadRequest_FieldViolation: the created field violation

func (DefaultErrorDetailsGenerator) NewSingleBadRequest added in v0.4.3

func (d DefaultErrorDetailsGenerator) NewSingleBadRequest(field, description string) *errdetails.BadRequest

NewSingleBadRequest creates a new bad request with a single field violation

Parameters:

  • field: the field that caused the violation
  • description: a description of the violation

Returns:

  • *errdetails.BadRequest: the created bad request

func (DefaultErrorDetailsGenerator) NewSingleFieldViolation added in v0.4.3

func (d DefaultErrorDetailsGenerator) NewSingleFieldViolation(
	field, description string,
) []*errdetails.BadRequest_FieldViolation

NewSingleFieldViolation creates a new bad request with a single field violation

Parameters:

  • field: the field that caused the violation
  • description: a description of the violation

Returns:

  • []*errdetails.BadRequest_FieldViolation: the created field violations

func (DefaultErrorDetailsGenerator) NewStructSingleFieldBadRequest added in v0.4.3

func (d DefaultErrorDetailsGenerator) NewStructSingleFieldBadRequest(
	structExample any,
	field, description string,
) *errdetails.BadRequest

NewStructSingleFieldBadRequest creates a new bad request with a single field violation for a struct field

Parameters:

  • structExample: the struct example
  • field: the field that caused the violation
  • description: a description of the violation

Returns:

  • *errdetails.BadRequest: the created bad request

type ErrorDetailsGenerator added in v0.4.3

type ErrorDetailsGenerator interface {
	NewFieldViolation(field, description string) *errdetails.BadRequest_FieldViolation
	NewSingleFieldViolation(field, description string) []*errdetails.BadRequest_FieldViolation
	NewBadRequest(violations []*errdetails.BadRequest_FieldViolation) *errdetails.BadRequest
	NewSingleBadRequest(field, description string) *errdetails.BadRequest
	NewStructSingleFieldBadRequest(structExample any, field, description string) *errdetails.BadRequest
}

ErrorDetailsGenerator interface for generating gRPC error details

Jump to

Keyboard shortcuts

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