turnip

package
v0.0.0-...-d53460a Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TurnipPathPrefix = "/twirp/turnipxenon.v1.Turnip/"

TurnipPathPrefix 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 File_rpc_turnip_service_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 AccessDetails

type AccessDetails struct {
	AllowedDomains []string `protobuf:"bytes,1,rep,name=allowed_domains,json=allowedDomains,proto3" json:"allowed_domains,omitempty"`
	// contains filtered or unexported fields
}

func (*AccessDetails) Descriptor deprecated

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

Deprecated: Use AccessDetails.ProtoReflect.Descriptor instead.

func (*AccessDetails) GetAllowedDomains

func (x *AccessDetails) GetAllowedDomains() []string

func (*AccessDetails) ProtoMessage

func (*AccessDetails) ProtoMessage()

func (*AccessDetails) ProtoReflect

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

func (*AccessDetails) Reset

func (x *AccessDetails) Reset()

func (*AccessDetails) String

func (x *AccessDetails) String() string

type Content

type Content struct {
	Title         string                 `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	Description   string                 `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	Content       string                 `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"`
	Media         *string                `protobuf:"bytes,4,opt,name=media,proto3,oneof" json:"media,omitempty"`
	TagList       []string               `protobuf:"bytes,5,rep,name=tag_list,json=tagList,proto3" json:"tag_list,omitempty"`
	AccessDetails *AccessDetails         `protobuf:"bytes,6,opt,name=access_details,json=accessDetails,proto3" json:"access_details,omitempty"`
	Meta          map[string]string      `` /* 149-byte string literal not displayed */
	PrimaryId     string                 `protobuf:"bytes,8,opt,name=primary_id,json=primaryId,proto3" json:"primary_id,omitempty"`
	CreatedAt     *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	AuthorId      string                 `protobuf:"bytes,10,opt,name=author_id,json=authorId,proto3" json:"author_id,omitempty"`
	Slug          *string                `protobuf:"bytes,11,opt,name=slug,proto3,oneof" json:"slug,omitempty"`
	Placeholder   *string                `protobuf:"bytes,12,opt,name=placeholder,proto3,oneof" json:"placeholder,omitempty"` // todo: reserve 12 to not break future versions
	// contains filtered or unexported fields
}

func (*Content) Descriptor deprecated

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

Deprecated: Use Content.ProtoReflect.Descriptor instead.

func (*Content) GetAccessDetails

func (x *Content) GetAccessDetails() *AccessDetails

func (*Content) GetAuthorId

func (x *Content) GetAuthorId() string

func (*Content) GetContent

func (x *Content) GetContent() string

func (*Content) GetCreatedAt

func (x *Content) GetCreatedAt() *timestamppb.Timestamp

func (*Content) GetDescription

func (x *Content) GetDescription() string

func (*Content) GetMedia

func (x *Content) GetMedia() string

func (*Content) GetMeta

func (x *Content) GetMeta() map[string]string

func (*Content) GetPlaceholder

func (x *Content) GetPlaceholder() string

func (*Content) GetPrimaryId

func (x *Content) GetPrimaryId() string

func (*Content) GetSlug

func (x *Content) GetSlug() string

func (*Content) GetTagList

func (x *Content) GetTagList() []string

func (*Content) GetTitle

func (x *Content) GetTitle() string

func (*Content) ProtoMessage

func (*Content) ProtoMessage()

func (*Content) ProtoReflect

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

func (*Content) Reset

func (x *Content) Reset()

func (*Content) String

func (x *Content) String() string

type ContentRequestResponse

type ContentRequestResponse struct {
	Item *Content `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
	// contains filtered or unexported fields
}

func (*ContentRequestResponse) Descriptor deprecated

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

Deprecated: Use ContentRequestResponse.ProtoReflect.Descriptor instead.

func (*ContentRequestResponse) GetItem

func (x *ContentRequestResponse) GetItem() *Content

func (*ContentRequestResponse) ProtoMessage

func (*ContentRequestResponse) ProtoMessage()

func (*ContentRequestResponse) ProtoReflect

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

func (*ContentRequestResponse) Reset

func (x *ContentRequestResponse) Reset()

func (*ContentRequestResponse) String

func (x *ContentRequestResponse) String() string

type CreateUserRequest

type CreateUserRequest struct {
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

region request and responses

func (*CreateUserRequest) Descriptor deprecated

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

Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.

func (*CreateUserRequest) GetPassword

func (x *CreateUserRequest) GetPassword() string

func (*CreateUserRequest) GetUsername

func (x *CreateUserRequest) GetUsername() 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 {
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // using msg to follow twirp's format
	// contains filtered or unexported fields
}

func (*CreateUserResponse) Descriptor deprecated

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

Deprecated: Use CreateUserResponse.ProtoReflect.Descriptor instead.

func (*CreateUserResponse) GetMsg

func (x *CreateUserResponse) GetMsg() string

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 GetAllContentRequest

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

func (*GetAllContentRequest) Descriptor deprecated

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

Deprecated: Use GetAllContentRequest.ProtoReflect.Descriptor instead.

func (*GetAllContentRequest) ProtoMessage

func (*GetAllContentRequest) ProtoMessage()

func (*GetAllContentRequest) ProtoReflect

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

func (*GetAllContentRequest) Reset

func (x *GetAllContentRequest) Reset()

func (*GetAllContentRequest) String

func (x *GetAllContentRequest) String() string

type GetContentByIdResponse

type GetContentByIdResponse struct {
	Item *Content `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
	// contains filtered or unexported fields
}

func (*GetContentByIdResponse) Descriptor deprecated

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

Deprecated: Use GetContentByIdResponse.ProtoReflect.Descriptor instead.

func (*GetContentByIdResponse) GetItem

func (x *GetContentByIdResponse) GetItem() *Content

func (*GetContentByIdResponse) ProtoMessage

func (*GetContentByIdResponse) ProtoMessage()

func (*GetContentByIdResponse) ProtoReflect

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

func (*GetContentByIdResponse) Reset

func (x *GetContentByIdResponse) Reset()

func (*GetContentByIdResponse) String

func (x *GetContentByIdResponse) String() string

type GetContentBySlugRequest

type GetContentBySlugRequest struct {
	Slug string `protobuf:"bytes,1,opt,name=slug,proto3" json:"slug,omitempty"`
	// contains filtered or unexported fields
}

func (*GetContentBySlugRequest) Descriptor deprecated

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

Deprecated: Use GetContentBySlugRequest.ProtoReflect.Descriptor instead.

func (*GetContentBySlugRequest) GetSlug

func (x *GetContentBySlugRequest) GetSlug() string

func (*GetContentBySlugRequest) ProtoMessage

func (*GetContentBySlugRequest) ProtoMessage()

func (*GetContentBySlugRequest) ProtoReflect

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

func (*GetContentBySlugRequest) Reset

func (x *GetContentBySlugRequest) Reset()

func (*GetContentBySlugRequest) String

func (x *GetContentBySlugRequest) String() string

type GetContentsByTagRequest

type GetContentsByTagRequest struct {
	TagList []string `protobuf:"bytes,1,rep,name=tag_list,json=tagList,proto3" json:"tag_list,omitempty"`
	// contains filtered or unexported fields
}

func (*GetContentsByTagRequest) Descriptor deprecated

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

Deprecated: Use GetContentsByTagRequest.ProtoReflect.Descriptor instead.

func (*GetContentsByTagRequest) GetTagList

func (x *GetContentsByTagRequest) GetTagList() []string

func (*GetContentsByTagRequest) ProtoMessage

func (*GetContentsByTagRequest) ProtoMessage()

func (*GetContentsByTagRequest) ProtoReflect

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

func (*GetContentsByTagRequest) Reset

func (x *GetContentsByTagRequest) Reset()

func (*GetContentsByTagRequest) String

func (x *GetContentsByTagRequest) 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 LoginRequest

type LoginRequest struct {
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

func (*LoginRequest) Descriptor deprecated

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

Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead.

func (*LoginRequest) GetPassword

func (x *LoginRequest) GetPassword() string

func (*LoginRequest) GetUsername

func (x *LoginRequest) GetUsername() string

func (*LoginRequest) ProtoMessage

func (*LoginRequest) ProtoMessage()

func (*LoginRequest) ProtoReflect

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

func (*LoginRequest) Reset

func (x *LoginRequest) Reset()

func (*LoginRequest) String

func (x *LoginRequest) String() string

type LoginResponse

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

func (*LoginResponse) Descriptor deprecated

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

Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead.

func (*LoginResponse) GetToken

func (x *LoginResponse) GetToken() *Token

func (*LoginResponse) GetUser

func (x *LoginResponse) GetUser() *User

func (*LoginResponse) ProtoMessage

func (*LoginResponse) ProtoMessage()

func (*LoginResponse) ProtoReflect

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

func (*LoginResponse) Reset

func (x *LoginResponse) Reset()

func (*LoginResponse) String

func (x *LoginResponse) String() string

type MultipleContentResponse

type MultipleContentResponse struct {
	ItemList []*Content `protobuf:"bytes,1,rep,name=item_list,json=itemList,proto3" json:"item_list,omitempty"`
	// contains filtered or unexported fields
}

func (*MultipleContentResponse) Descriptor deprecated

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

Deprecated: Use MultipleContentResponse.ProtoReflect.Descriptor instead.

func (*MultipleContentResponse) GetItemList

func (x *MultipleContentResponse) GetItemList() []*Content

func (*MultipleContentResponse) ProtoMessage

func (*MultipleContentResponse) ProtoMessage()

func (*MultipleContentResponse) ProtoReflect

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

func (*MultipleContentResponse) Reset

func (x *MultipleContentResponse) Reset()

func (*MultipleContentResponse) String

func (x *MultipleContentResponse) String() string

type MultiplePrimaryIdRequest

type MultiplePrimaryIdRequest struct {
	PrimaryIdList []string `protobuf:"bytes,1,rep,name=primary_id_list,json=primaryIdList,proto3" json:"primary_id_list,omitempty"`
	// contains filtered or unexported fields
}

func (*MultiplePrimaryIdRequest) Descriptor deprecated

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

Deprecated: Use MultiplePrimaryIdRequest.ProtoReflect.Descriptor instead.

func (*MultiplePrimaryIdRequest) GetPrimaryIdList

func (x *MultiplePrimaryIdRequest) GetPrimaryIdList() []string

func (*MultiplePrimaryIdRequest) ProtoMessage

func (*MultiplePrimaryIdRequest) ProtoMessage()

func (*MultiplePrimaryIdRequest) ProtoReflect

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

func (*MultiplePrimaryIdRequest) Reset

func (x *MultiplePrimaryIdRequest) Reset()

func (*MultiplePrimaryIdRequest) String

func (x *MultiplePrimaryIdRequest) String() string

type PrimaryIdRequest

type PrimaryIdRequest struct {
	PrimaryId string `protobuf:"bytes,1,opt,name=primary_id,json=primaryId,proto3" json:"primary_id,omitempty"`
	// contains filtered or unexported fields
}

func (*PrimaryIdRequest) Descriptor deprecated

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

Deprecated: Use PrimaryIdRequest.ProtoReflect.Descriptor instead.

func (*PrimaryIdRequest) GetPrimaryId

func (x *PrimaryIdRequest) GetPrimaryId() string

func (*PrimaryIdRequest) ProtoMessage

func (*PrimaryIdRequest) ProtoMessage()

func (*PrimaryIdRequest) ProtoReflect

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

func (*PrimaryIdRequest) Reset

func (x *PrimaryIdRequest) Reset()

func (*PrimaryIdRequest) String

func (x *PrimaryIdRequest) String() string

type RevalidateStaticPathRequest

type RevalidateStaticPathRequest struct {
	Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

func (*RevalidateStaticPathRequest) Descriptor deprecated

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

Deprecated: Use RevalidateStaticPathRequest.ProtoReflect.Descriptor instead.

func (*RevalidateStaticPathRequest) GetPath

func (x *RevalidateStaticPathRequest) GetPath() string

func (*RevalidateStaticPathRequest) ProtoMessage

func (*RevalidateStaticPathRequest) ProtoMessage()

func (*RevalidateStaticPathRequest) ProtoReflect

func (*RevalidateStaticPathRequest) Reset

func (x *RevalidateStaticPathRequest) Reset()

func (*RevalidateStaticPathRequest) String

func (x *RevalidateStaticPathRequest) String() string

type RevalidateStaticPathResponse

type RevalidateStaticPathResponse struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*RevalidateStaticPathResponse) Descriptor deprecated

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

Deprecated: Use RevalidateStaticPathResponse.ProtoReflect.Descriptor instead.

func (*RevalidateStaticPathResponse) GetMessage

func (x *RevalidateStaticPathResponse) GetMessage() string

func (*RevalidateStaticPathResponse) ProtoMessage

func (*RevalidateStaticPathResponse) ProtoMessage()

func (*RevalidateStaticPathResponse) ProtoReflect

func (*RevalidateStaticPathResponse) Reset

func (x *RevalidateStaticPathResponse) Reset()

func (*RevalidateStaticPathResponse) String

type Token

type Token struct {
	AccessToken string                 `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
	Username    string                 `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // special case; otherwise use uuid
	CreatedAt   *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	ExpiresAt   *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
	// contains filtered or unexported fields
}

func (*Token) Descriptor deprecated

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

Deprecated: Use Token.ProtoReflect.Descriptor instead.

func (*Token) GetAccessToken

func (x *Token) GetAccessToken() string

func (*Token) GetCreatedAt

func (x *Token) GetCreatedAt() *timestamppb.Timestamp

func (*Token) GetExpiresAt

func (x *Token) GetExpiresAt() *timestamppb.Timestamp

func (*Token) GetUsername

func (x *Token) GetUsername() string

func (*Token) ProtoMessage

func (*Token) ProtoMessage()

func (*Token) ProtoReflect

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

func (*Token) Reset

func (x *Token) Reset()

func (*Token) String

func (x *Token) String() string

type Turnip

type Turnip interface {
	CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)

	Login(context.Context, *LoginRequest) (*LoginResponse, error)

	CreateContent(context.Context, *ContentRequestResponse) (*ContentRequestResponse, error)

	GetContentById(context.Context, *PrimaryIdRequest) (*ContentRequestResponse, error)

	GetContentBatchById(context.Context, *PrimaryIdRequest) (*MultipleContentResponse, error)

	GetAllContent(context.Context, *GetAllContentRequest) (*MultipleContentResponse, error)

	// inclusive or, will return contents with at least one of the tags
	GetContentsByTagInclusive(context.Context, *GetContentsByTagRequest) (*MultipleContentResponse, error)

	// strict and, will only return contents with the following tags
	GetContentsByTagStrict(context.Context, *GetContentsByTagRequest) (*MultipleContentResponse, error)

	// todo: GetAllContentByTag (make a tree like structure? is that possible?)
	UpdateContent(context.Context, *ContentRequestResponse) (*ContentRequestResponse, error)

	DeleteContent(context.Context, *PrimaryIdRequest) (*ContentRequestResponse, error)

	GetContentBySlug(context.Context, *GetContentBySlugRequest) (*ContentRequestResponse, error)

	RevalidateStaticPath(context.Context, *RevalidateStaticPathRequest) (*RevalidateStaticPathResponse, error)
}

Turnip handles all processes to internal services

func NewTurnipJSONClient

func NewTurnipJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Turnip

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

func NewTurnipProtobufClient

func NewTurnipProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Turnip

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

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 NewTurnipServer

func NewTurnipServer(svc Turnip, opts ...interface{}) TwirpServer

NewTurnipServer 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 {
	Username  string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	PrimaryId string `protobuf:"bytes,2,opt,name=primary_id,json=primaryId,proto3" json:"primary_id,omitempty"`
	// contains filtered or unexported fields
}

region models

func (*User) Descriptor deprecated

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

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetPrimaryId

func (x *User) GetPrimaryId() string

func (*User) GetUsername

func (x *User) GetUsername() 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

Jump to

Keyboard shortcuts

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