userpb

package
v0.0.0-...-4a7ca2a Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const UserServicePathPrefix = "/twirp/proto.user.v1.UserService/"

UserServicePathPrefix is a convenience constant that may identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, with the default "/twirp" prefix and default CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html

Variables

View Source
var (
	UserRole_name = map[int32]string{
		0: "USER_ROLE_UNSPECIFIED",
		1: "USER_ROLE_READONLY",
		2: "USER_ROLE_ADMIN",
	}
	UserRole_value = map[string]int32{
		"USER_ROLE_UNSPECIFIED": 0,
		"USER_ROLE_READONLY":    1,
		"USER_ROLE_ADMIN":       2,
	}
)

Enum value maps for UserRole.

View Source
var File_proto_user_v1_user_proto protoreflect.FileDescriptor

Functions

func WriteError

func WriteError(resp http.ResponseWriter, err error)

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type GetUserRequest

type GetUserRequest struct {
	OrganisationId string `protobuf:"bytes,1,opt,name=organisation_id,json=organisationId,proto3" json:"organisation_id,omitempty"`
	UserId         string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUserRequest) Descriptor deprecated

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

Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.

func (*GetUserRequest) GetOrganisationId

func (x *GetUserRequest) GetOrganisationId() string

func (*GetUserRequest) GetUserId

func (x *GetUserRequest) GetUserId() string

func (*GetUserRequest) ProtoMessage

func (*GetUserRequest) ProtoMessage()

func (*GetUserRequest) ProtoReflect

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

func (*GetUserRequest) Reset

func (x *GetUserRequest) Reset()

func (*GetUserRequest) String

func (x *GetUserRequest) String() string

type GetUserResponse

type GetUserResponse struct {
	User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

func (*GetUserResponse) Descriptor deprecated

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

Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.

func (*GetUserResponse) GetUser

func (x *GetUserResponse) GetUser() *User

func (*GetUserResponse) ProtoMessage

func (*GetUserResponse) ProtoMessage()

func (*GetUserResponse) ProtoReflect

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

func (*GetUserResponse) Reset

func (x *GetUserResponse) Reset()

func (*GetUserResponse) String

func (x *GetUserResponse) String() string

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

type StoreUserRequest

type StoreUserRequest struct {
	OrganisationId string   `protobuf:"bytes,1,opt,name=organisation_id,json=organisationId,proto3" json:"organisation_id,omitempty"`
	FirstName      string   `protobuf:"bytes,3,opt,name=first_name,json=firstName,proto3" json:"first_name,omitempty"`
	LastName       string   `protobuf:"bytes,4,opt,name=last_name,json=lastName,proto3" json:"last_name,omitempty"`
	Role           UserRole `protobuf:"varint,5,opt,name=role,proto3,enum=proto.user.v1.UserRole" json:"role,omitempty"`
	// contains filtered or unexported fields
}

func (*StoreUserRequest) Descriptor deprecated

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

Deprecated: Use StoreUserRequest.ProtoReflect.Descriptor instead.

func (*StoreUserRequest) GetFirstName

func (x *StoreUserRequest) GetFirstName() string

func (*StoreUserRequest) GetLastName

func (x *StoreUserRequest) GetLastName() string

func (*StoreUserRequest) GetOrganisationId

func (x *StoreUserRequest) GetOrganisationId() string

func (*StoreUserRequest) GetRole

func (x *StoreUserRequest) GetRole() UserRole

func (*StoreUserRequest) ProtoMessage

func (*StoreUserRequest) ProtoMessage()

func (*StoreUserRequest) ProtoReflect

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

func (*StoreUserRequest) Reset

func (x *StoreUserRequest) Reset()

func (*StoreUserRequest) String

func (x *StoreUserRequest) String() string

type StoreUserResponse

type StoreUserResponse struct {
	OrganisationId string `protobuf:"bytes,1,opt,name=organisation_id,json=organisationId,proto3" json:"organisation_id,omitempty"`
	UserId         string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// contains filtered or unexported fields
}

func (*StoreUserResponse) Descriptor deprecated

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

Deprecated: Use StoreUserResponse.ProtoReflect.Descriptor instead.

func (*StoreUserResponse) GetOrganisationId

func (x *StoreUserResponse) GetOrganisationId() string

func (*StoreUserResponse) GetUserId

func (x *StoreUserResponse) GetUserId() string

func (*StoreUserResponse) ProtoMessage

func (*StoreUserResponse) ProtoMessage()

func (*StoreUserResponse) ProtoReflect

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

func (*StoreUserResponse) Reset

func (x *StoreUserResponse) Reset()

func (*StoreUserResponse) String

func (x *StoreUserResponse) String() string

type TwirpServer

type TwirpServer interface {
	http.Handler

	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)

	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string

	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route Twirp requests.
	// The path prefix is in the form: "/<prefix>/<package>.<Service>/"
	// that is, everything in a Twirp route except for the <Method> at the end.
	PathPrefix() string
}

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

func NewUserServiceServer

func NewUserServiceServer(svc UserService, opts ...interface{}) TwirpServer

NewUserServiceServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).

type User

type User struct {
	OrganisationId string   `protobuf:"bytes,1,opt,name=organisation_id,json=organisationId,proto3" json:"organisation_id,omitempty"`
	UserId         string   `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	FirstName      string   `protobuf:"bytes,3,opt,name=first_name,json=firstName,proto3" json:"first_name,omitempty"`
	LastName       string   `protobuf:"bytes,4,opt,name=last_name,json=lastName,proto3" json:"last_name,omitempty"`
	Role           UserRole `protobuf:"varint,5,opt,name=role,proto3,enum=proto.user.v1.UserRole" json:"role,omitempty"`
	// contains filtered or unexported fields
}

func (*User) Descriptor deprecated

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

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetFirstName

func (x *User) GetFirstName() string

func (*User) GetLastName

func (x *User) GetLastName() string

func (*User) GetOrganisationId

func (x *User) GetOrganisationId() string

func (*User) GetRole

func (x *User) GetRole() UserRole

func (*User) GetUserId

func (x *User) GetUserId() string

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

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

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type UserRole

type UserRole int32
const (
	UserRole_USER_ROLE_UNSPECIFIED UserRole = 0
	UserRole_USER_ROLE_READONLY    UserRole = 1
	UserRole_USER_ROLE_ADMIN       UserRole = 2
)

func (UserRole) Descriptor

func (UserRole) Descriptor() protoreflect.EnumDescriptor

func (UserRole) Enum

func (x UserRole) Enum() *UserRole

func (UserRole) EnumDescriptor deprecated

func (UserRole) EnumDescriptor() ([]byte, []int)

Deprecated: Use UserRole.Descriptor instead.

func (UserRole) Number

func (x UserRole) Number() protoreflect.EnumNumber

func (UserRole) String

func (x UserRole) String() string

func (UserRole) Type

type UserService

type UserService interface {
	GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)

	StoreUser(context.Context, *StoreUserRequest) (*StoreUserResponse, error)
}

func NewUserServiceJSONClient

func NewUserServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) UserService

NewUserServiceJSONClient creates a JSON client that implements the UserService interface. It communicates using JSON and can be configured with a custom HTTPClient.

func NewUserServiceProtobufClient

func NewUserServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) UserService

NewUserServiceProtobufClient creates a Protobuf client that implements the UserService interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

Jump to

Keyboard shortcuts

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