Documentation
¶
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type CreateUserRequest
- func (*CreateUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateUserRequest) GetBio() string
- func (x *CreateUserRequest) GetBirthDate() *timestamp.Timestamp
- func (x *CreateUserRequest) GetEmail() string
- func (x *CreateUserRequest) GetLocation() string
- func (x *CreateUserRequest) GetName() string
- func (x *CreateUserRequest) GetPassword() string
- func (x *CreateUserRequest) GetProfileBannerUrl() string
- func (x *CreateUserRequest) GetProfileImageUrl() string
- func (x *CreateUserRequest) GetScreenName() string
- func (x *CreateUserRequest) GetWebsite() string
- func (*CreateUserRequest) ProtoMessage()
- func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
- func (x *CreateUserRequest) Reset()
- func (x *CreateUserRequest) String() string
- type CreateUserResponse
- type DeleteUserRequest
- type DeleteUserResponse
- func (*DeleteUserResponse) Descriptor() ([]byte, []int)deprecated
- func (x *DeleteUserResponse) GetSuccess() bool
- func (*DeleteUserResponse) ProtoMessage()
- func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message
- func (x *DeleteUserResponse) Reset()
- func (x *DeleteUserResponse) String() string
- type FindUserByEmailRequest
- func (*FindUserByEmailRequest) Descriptor() ([]byte, []int)deprecated
- func (x *FindUserByEmailRequest) GetEmail() string
- func (*FindUserByEmailRequest) ProtoMessage()
- func (x *FindUserByEmailRequest) ProtoReflect() protoreflect.Message
- func (x *FindUserByEmailRequest) Reset()
- func (x *FindUserByEmailRequest) String() string
- type FindUserByEmailResponse
- func (*FindUserByEmailResponse) Descriptor() ([]byte, []int)deprecated
- func (x *FindUserByEmailResponse) GetUser() *User
- func (*FindUserByEmailResponse) ProtoMessage()
- func (x *FindUserByEmailResponse) ProtoReflect() protoreflect.Message
- func (x *FindUserByEmailResponse) Reset()
- func (x *FindUserByEmailResponse) String() string
- type FindUserByIDRequest
- func (*FindUserByIDRequest) Descriptor() ([]byte, []int)deprecated
- func (x *FindUserByIDRequest) GetUserId() string
- func (*FindUserByIDRequest) ProtoMessage()
- func (x *FindUserByIDRequest) ProtoReflect() protoreflect.Message
- func (x *FindUserByIDRequest) Reset()
- func (x *FindUserByIDRequest) String() string
- type FindUserByIDResponse
- func (*FindUserByIDResponse) Descriptor() ([]byte, []int)deprecated
- func (x *FindUserByIDResponse) GetUser() *User
- func (*FindUserByIDResponse) ProtoMessage()
- func (x *FindUserByIDResponse) ProtoReflect() protoreflect.Message
- func (x *FindUserByIDResponse) Reset()
- func (x *FindUserByIDResponse) String() string
- type HTTPClient
- type TwirpServer
- type User
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetBio() string
- func (x *User) GetBirthDate() *timestamp.Timestamp
- func (x *User) GetCreatedAt() *timestamp.Timestamp
- func (x *User) GetEmail() string
- func (x *User) GetFollowersCount() int32
- func (x *User) GetFollowingsCount() int32
- func (x *User) GetLocation() string
- func (x *User) GetName() string
- func (x *User) GetPasswordHash() string
- func (x *User) GetProfileBannerUrl() string
- func (x *User) GetProfileImageUrl() string
- func (x *User) GetScreenName() string
- func (x *User) GetUpdatedAt() *timestamp.Timestamp
- func (x *User) GetUserId() string
- func (x *User) GetWebsite() string
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (x *User) String() string
- type UserService
Constants ¶
const UserServicePathPrefix = "/twirp/hotpotatoc.twitter_clone.user.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 ¶
var File_rpc_user_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 CreateUserRequest ¶
type CreateUserRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` ScreenName string `protobuf:"bytes,2,opt,name=screen_name,json=screenName,proto3" json:"screen_name,omitempty"` Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` Email string `protobuf:"bytes,4,opt,name=email,proto3" json:"email,omitempty"` Bio string `protobuf:"bytes,5,opt,name=bio,proto3" json:"bio,omitempty"` Location string `protobuf:"bytes,6,opt,name=location,proto3" json:"location,omitempty"` Website string `protobuf:"bytes,7,opt,name=website,proto3" json:"website,omitempty"` ProfileImageUrl string `protobuf:"bytes,8,opt,name=profile_image_url,json=profileImageUrl,proto3" json:"profile_image_url,omitempty"` ProfileBannerUrl string `protobuf:"bytes,9,opt,name=profile_banner_url,json=profileBannerUrl,proto3" json:"profile_banner_url,omitempty"` BirthDate *timestamp.Timestamp `protobuf:"bytes,10,opt,name=birth_date,json=birthDate,proto3" json:"birth_date,omitempty"` // contains filtered or unexported fields }
CreateUserRequest request body for CreateUser
func (*CreateUserRequest) Descriptor
deprecated
func (*CreateUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.
func (*CreateUserRequest) GetBio ¶
func (x *CreateUserRequest) GetBio() string
func (*CreateUserRequest) GetBirthDate ¶
func (x *CreateUserRequest) GetBirthDate() *timestamp.Timestamp
func (*CreateUserRequest) GetEmail ¶
func (x *CreateUserRequest) GetEmail() string
func (*CreateUserRequest) GetLocation ¶
func (x *CreateUserRequest) GetLocation() string
func (*CreateUserRequest) GetName ¶
func (x *CreateUserRequest) GetName() string
func (*CreateUserRequest) GetPassword ¶
func (x *CreateUserRequest) GetPassword() string
func (*CreateUserRequest) GetProfileBannerUrl ¶
func (x *CreateUserRequest) GetProfileBannerUrl() string
func (*CreateUserRequest) GetProfileImageUrl ¶
func (x *CreateUserRequest) GetProfileImageUrl() string
func (*CreateUserRequest) GetScreenName ¶
func (x *CreateUserRequest) GetScreenName() string
func (*CreateUserRequest) GetWebsite ¶
func (x *CreateUserRequest) GetWebsite() string
func (*CreateUserRequest) ProtoMessage ¶
func (*CreateUserRequest) ProtoMessage()
func (*CreateUserRequest) ProtoReflect ¶
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
func (*CreateUserRequest) Reset ¶
func (x *CreateUserRequest) Reset()
func (*CreateUserRequest) String ¶
func (x *CreateUserRequest) String() string
type CreateUserResponse ¶
type CreateUserResponse struct { User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // contains filtered or unexported fields }
CreateUserResponse response body for CreateUser
func (*CreateUserResponse) Descriptor
deprecated
func (*CreateUserResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateUserResponse.ProtoReflect.Descriptor instead.
func (*CreateUserResponse) GetUser ¶
func (x *CreateUserResponse) GetUser() *User
func (*CreateUserResponse) ProtoMessage ¶
func (*CreateUserResponse) ProtoMessage()
func (*CreateUserResponse) ProtoReflect ¶
func (x *CreateUserResponse) ProtoReflect() protoreflect.Message
func (*CreateUserResponse) Reset ¶
func (x *CreateUserResponse) Reset()
func (*CreateUserResponse) String ¶
func (x *CreateUserResponse) String() string
type DeleteUserRequest ¶
type DeleteUserRequest struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // contains filtered or unexported fields }
DeleteUserRequest request body for DeleteUser
func (*DeleteUserRequest) Descriptor
deprecated
func (*DeleteUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead.
func (*DeleteUserRequest) GetUserId ¶
func (x *DeleteUserRequest) GetUserId() string
func (*DeleteUserRequest) ProtoMessage ¶
func (*DeleteUserRequest) ProtoMessage()
func (*DeleteUserRequest) ProtoReflect ¶
func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message
func (*DeleteUserRequest) Reset ¶
func (x *DeleteUserRequest) Reset()
func (*DeleteUserRequest) String ¶
func (x *DeleteUserRequest) String() string
type DeleteUserResponse ¶
type DeleteUserResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // contains filtered or unexported fields }
DeleteUserResponse response body for DeleteUser
func (*DeleteUserResponse) Descriptor
deprecated
func (*DeleteUserResponse) Descriptor() ([]byte, []int)
Deprecated: Use DeleteUserResponse.ProtoReflect.Descriptor instead.
func (*DeleteUserResponse) GetSuccess ¶
func (x *DeleteUserResponse) GetSuccess() bool
func (*DeleteUserResponse) ProtoMessage ¶
func (*DeleteUserResponse) ProtoMessage()
func (*DeleteUserResponse) ProtoReflect ¶
func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message
func (*DeleteUserResponse) Reset ¶
func (x *DeleteUserResponse) Reset()
func (*DeleteUserResponse) String ¶
func (x *DeleteUserResponse) String() string
type FindUserByEmailRequest ¶
type FindUserByEmailRequest struct { Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` // contains filtered or unexported fields }
FindUserByEmailRequest request body for FindUserByEmail
func (*FindUserByEmailRequest) Descriptor
deprecated
func (*FindUserByEmailRequest) Descriptor() ([]byte, []int)
Deprecated: Use FindUserByEmailRequest.ProtoReflect.Descriptor instead.
func (*FindUserByEmailRequest) GetEmail ¶
func (x *FindUserByEmailRequest) GetEmail() string
func (*FindUserByEmailRequest) ProtoMessage ¶
func (*FindUserByEmailRequest) ProtoMessage()
func (*FindUserByEmailRequest) ProtoReflect ¶
func (x *FindUserByEmailRequest) ProtoReflect() protoreflect.Message
func (*FindUserByEmailRequest) Reset ¶
func (x *FindUserByEmailRequest) Reset()
func (*FindUserByEmailRequest) String ¶
func (x *FindUserByEmailRequest) String() string
type FindUserByEmailResponse ¶
type FindUserByEmailResponse struct { User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // contains filtered or unexported fields }
FindUserByEmailResponse response body for FindUserByEmail
func (*FindUserByEmailResponse) Descriptor
deprecated
func (*FindUserByEmailResponse) Descriptor() ([]byte, []int)
Deprecated: Use FindUserByEmailResponse.ProtoReflect.Descriptor instead.
func (*FindUserByEmailResponse) GetUser ¶
func (x *FindUserByEmailResponse) GetUser() *User
func (*FindUserByEmailResponse) ProtoMessage ¶
func (*FindUserByEmailResponse) ProtoMessage()
func (*FindUserByEmailResponse) ProtoReflect ¶
func (x *FindUserByEmailResponse) ProtoReflect() protoreflect.Message
func (*FindUserByEmailResponse) Reset ¶
func (x *FindUserByEmailResponse) Reset()
func (*FindUserByEmailResponse) String ¶
func (x *FindUserByEmailResponse) String() string
type FindUserByIDRequest ¶
type FindUserByIDRequest struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // contains filtered or unexported fields }
FindUserByIDRequest request body for FindUserByID
func (*FindUserByIDRequest) Descriptor
deprecated
func (*FindUserByIDRequest) Descriptor() ([]byte, []int)
Deprecated: Use FindUserByIDRequest.ProtoReflect.Descriptor instead.
func (*FindUserByIDRequest) GetUserId ¶
func (x *FindUserByIDRequest) GetUserId() string
func (*FindUserByIDRequest) ProtoMessage ¶
func (*FindUserByIDRequest) ProtoMessage()
func (*FindUserByIDRequest) ProtoReflect ¶
func (x *FindUserByIDRequest) ProtoReflect() protoreflect.Message
func (*FindUserByIDRequest) Reset ¶
func (x *FindUserByIDRequest) Reset()
func (*FindUserByIDRequest) String ¶
func (x *FindUserByIDRequest) String() string
type FindUserByIDResponse ¶
type FindUserByIDResponse struct { User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // contains filtered or unexported fields }
FindUserByIDResponse response body for FindUserByID
func (*FindUserByIDResponse) Descriptor
deprecated
func (*FindUserByIDResponse) Descriptor() ([]byte, []int)
Deprecated: Use FindUserByIDResponse.ProtoReflect.Descriptor instead.
func (*FindUserByIDResponse) GetUser ¶
func (x *FindUserByIDResponse) GetUser() *User
func (*FindUserByIDResponse) ProtoMessage ¶
func (*FindUserByIDResponse) ProtoMessage()
func (*FindUserByIDResponse) ProtoReflect ¶
func (x *FindUserByIDResponse) ProtoReflect() protoreflect.Message
func (*FindUserByIDResponse) Reset ¶
func (x *FindUserByIDResponse) Reset()
func (*FindUserByIDResponse) String ¶
func (x *FindUserByIDResponse) String() string
type HTTPClient ¶
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 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 { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` ScreenName string `protobuf:"bytes,3,opt,name=screen_name,json=screenName,proto3" json:"screen_name,omitempty"` PasswordHash string `protobuf:"bytes,4,opt,name=password_hash,json=passwordHash,proto3" json:"password_hash,omitempty"` Email string `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"` Bio string `protobuf:"bytes,6,opt,name=bio,proto3" json:"bio,omitempty"` Location string `protobuf:"bytes,7,opt,name=location,proto3" json:"location,omitempty"` Website string `protobuf:"bytes,8,opt,name=website,proto3" json:"website,omitempty"` ProfileImageUrl string `protobuf:"bytes,9,opt,name=profile_image_url,json=profileImageUrl,proto3" json:"profile_image_url,omitempty"` ProfileBannerUrl string `protobuf:"bytes,10,opt,name=profile_banner_url,json=profileBannerUrl,proto3" json:"profile_banner_url,omitempty"` BirthDate *timestamp.Timestamp `protobuf:"bytes,11,opt,name=birth_date,json=birthDate,proto3" json:"birth_date,omitempty"` FollowersCount int32 `protobuf:"varint,12,opt,name=followers_count,json=followersCount,proto3" json:"followers_count,omitempty"` FollowingsCount int32 `protobuf:"varint,13,opt,name=followings_count,json=followingsCount,proto3" json:"followings_count,omitempty"` CreatedAt *timestamp.Timestamp `protobuf:"bytes,14,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamp.Timestamp `protobuf:"bytes,15,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
User represents the user model
func (*User) Descriptor
deprecated
func (*User) GetBirthDate ¶
func (*User) GetCreatedAt ¶
func (*User) GetFollowersCount ¶
func (*User) GetFollowingsCount ¶
func (*User) GetLocation ¶
func (*User) GetPasswordHash ¶
func (*User) GetProfileBannerUrl ¶
func (*User) GetProfileImageUrl ¶
func (*User) GetScreenName ¶
func (*User) GetUpdatedAt ¶
func (*User) GetWebsite ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
type UserService ¶
type UserService interface { // FindUserByID finds a user by id FindUserByID(context.Context, *FindUserByIDRequest) (*FindUserByIDResponse, error) // FindUserByEmail finds a user by email FindUserByEmail(context.Context, *FindUserByEmailRequest) (*FindUserByEmailResponse, error) // CreateUser creates a new user CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) // DeleteUser deletes an existing user DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) }
UserService service supports user management
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.