demo_app

package
v0.0.0-...-dd0a71d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const QuirksPathPrefix = "/twirp/quirks.v1.Quirks/"

QuirksPathPrefix 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

View Source
const SearchServicePathPrefix = "/twirp/SearchService/"

SearchServicePathPrefix 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 (
	RepeatedRequest_Enum_name = map[int32]string{
		0: "KEY_0",
		1: "KEY_1",
	}
	RepeatedRequest_Enum_value = map[string]int32{
		"KEY_0": 0,
		"KEY_1": 1,
	}
)

Enum value maps for RepeatedRequest_Enum.

View Source
var (
	Position_name = map[int32]string{
		0: "POSITION_TOP",
		1: "POSITION_BOTTOM",
	}
	Position_value = map[string]int32{
		"POSITION_TOP":    0,
		"POSITION_BOTTOM": 1,
	}
)

Enum value maps for Position.

View Source
var File_quirks_proto protoreflect.FileDescriptor
View Source
var File_search_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 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 IndexRequest

type IndexRequest struct {
	Result           *Result  `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
	Position         Position `protobuf:"varint,2,opt,name=position,proto3,enum=Position" json:"position,omitempty"`
	AdditionalCopies uint64   `protobuf:"varint,3,opt,name=additional_copies,json=additionalCopies,proto3" json:"additional_copies,omitempty"`
	// contains filtered or unexported fields
}

func (*IndexRequest) Descriptor deprecated

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

Deprecated: Use IndexRequest.ProtoReflect.Descriptor instead.

func (*IndexRequest) GetAdditionalCopies

func (x *IndexRequest) GetAdditionalCopies() uint64

func (*IndexRequest) GetPosition

func (x *IndexRequest) GetPosition() Position

func (*IndexRequest) GetResult

func (x *IndexRequest) GetResult() *Result

func (*IndexRequest) ProtoMessage

func (*IndexRequest) ProtoMessage()

func (*IndexRequest) ProtoReflect

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

func (*IndexRequest) Reset

func (x *IndexRequest) Reset()

func (*IndexRequest) String

func (x *IndexRequest) String() string

type IndexResponse

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

func (*IndexResponse) Descriptor deprecated

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

Deprecated: Use IndexResponse.ProtoReflect.Descriptor instead.

func (*IndexResponse) GetResult

func (x *IndexResponse) GetResult() *Result

func (*IndexResponse) ProtoMessage

func (*IndexResponse) ProtoMessage()

func (*IndexResponse) ProtoReflect

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

func (*IndexResponse) Reset

func (x *IndexResponse) Reset()

func (*IndexResponse) String

func (x *IndexResponse) String() string

type MapRequest

type MapRequest struct {
	StringString         map[string]string                     `` /* 185-byte string literal not displayed */
	StringInt32          map[string]int32                      `` /* 183-byte string literal not displayed */
	Sint64String         map[int64]string                      `` /* 188-byte string literal not displayed */
	StringRepeatedString map[string]*MapRequest_RepeatedString `` /* 211-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*MapRequest) Descriptor deprecated

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

Deprecated: Use MapRequest.ProtoReflect.Descriptor instead.

func (*MapRequest) GetSint64String

func (x *MapRequest) GetSint64String() map[int64]string

func (*MapRequest) GetStringInt32

func (x *MapRequest) GetStringInt32() map[string]int32

func (*MapRequest) GetStringRepeatedString

func (x *MapRequest) GetStringRepeatedString() map[string]*MapRequest_RepeatedString

func (*MapRequest) GetStringString

func (x *MapRequest) GetStringString() map[string]string

func (*MapRequest) ProtoMessage

func (*MapRequest) ProtoMessage()

func (*MapRequest) ProtoReflect

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

func (*MapRequest) Reset

func (x *MapRequest) Reset()

func (*MapRequest) String

func (x *MapRequest) String() string

type MapRequest_RepeatedString

type MapRequest_RepeatedString struct {
	Value []string `protobuf:"bytes,1,rep,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*MapRequest_RepeatedString) Descriptor deprecated

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

Deprecated: Use MapRequest_RepeatedString.ProtoReflect.Descriptor instead.

func (*MapRequest_RepeatedString) GetValue

func (x *MapRequest_RepeatedString) GetValue() []string

func (*MapRequest_RepeatedString) ProtoMessage

func (*MapRequest_RepeatedString) ProtoMessage()

func (*MapRequest_RepeatedString) ProtoReflect

func (*MapRequest_RepeatedString) Reset

func (x *MapRequest_RepeatedString) Reset()

func (*MapRequest_RepeatedString) String

func (x *MapRequest_RepeatedString) String() string

type Message

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

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetName

func (x *Message) GetName() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

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

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type Position

type Position int32
const (
	Position_POSITION_TOP    Position = 0
	Position_POSITION_BOTTOM Position = 1
)

func (Position) Descriptor

func (Position) Descriptor() protoreflect.EnumDescriptor

func (Position) Enum

func (x Position) Enum() *Position

func (Position) EnumDescriptor deprecated

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

Deprecated: Use Position.Descriptor instead.

func (Position) Number

func (x Position) Number() protoreflect.EnumNumber

func (Position) String

func (x Position) String() string

func (Position) Type

type Quirks

type Quirks interface {
	GetAuthentication(context.Context, *Void) (*Message, error)

	Map(context.Context, *MapRequest) (*MapRequest, error)

	MethodWithAReallyLongNameGmthggupcbmnphflnnvu(context.Context, *Void) (*Message, error)

	Panic(context.Context, *Void) (*Message, error)

	Repeated(context.Context, *RepeatedRequest) (*RepeatedRequest, error)

	Types(context.Context, *TypesRequest) (*TypesRequest, error)
}

func NewQuirksJSONClient

func NewQuirksJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Quirks

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

func NewQuirksProtobufClient

func NewQuirksProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Quirks

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

type RepeatedRequest

type RepeatedRequest struct {
	String_ []string               `protobuf:"bytes,1,rep,name=string,proto3" json:"string,omitempty"`
	Int32   []int32                `protobuf:"varint,2,rep,packed,name=int32,proto3" json:"int32,omitempty"`
	Enum    []RepeatedRequest_Enum `protobuf:"varint,3,rep,packed,name=enum,proto3,enum=quirks.v1.RepeatedRequest_Enum" json:"enum,omitempty"`
	Message []*Message             `protobuf:"bytes,4,rep,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*RepeatedRequest) Descriptor deprecated

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

Deprecated: Use RepeatedRequest.ProtoReflect.Descriptor instead.

func (*RepeatedRequest) GetEnum

func (x *RepeatedRequest) GetEnum() []RepeatedRequest_Enum

func (*RepeatedRequest) GetInt32

func (x *RepeatedRequest) GetInt32() []int32

func (*RepeatedRequest) GetMessage

func (x *RepeatedRequest) GetMessage() []*Message

func (*RepeatedRequest) GetString_

func (x *RepeatedRequest) GetString_() []string

func (*RepeatedRequest) ProtoMessage

func (*RepeatedRequest) ProtoMessage()

func (*RepeatedRequest) ProtoReflect

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

func (*RepeatedRequest) Reset

func (x *RepeatedRequest) Reset()

func (*RepeatedRequest) String

func (x *RepeatedRequest) String() string

type RepeatedRequest_Enum

type RepeatedRequest_Enum int32
const (
	RepeatedRequest_KEY_0 RepeatedRequest_Enum = 0
	RepeatedRequest_KEY_1 RepeatedRequest_Enum = 1
)

func (RepeatedRequest_Enum) Descriptor

func (RepeatedRequest_Enum) Enum

func (RepeatedRequest_Enum) EnumDescriptor deprecated

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

Deprecated: Use RepeatedRequest_Enum.Descriptor instead.

func (RepeatedRequest_Enum) Number

func (RepeatedRequest_Enum) String

func (x RepeatedRequest_Enum) String() string

func (RepeatedRequest_Enum) Type

type Result

type Result struct {
	Url      string   `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
	Title    string   `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
	Snippets []string `protobuf:"bytes,3,rep,name=snippets,proto3" json:"snippets,omitempty"`
	IsAd     bool     `protobuf:"varint,4,opt,name=is_ad,json=isAd,proto3" json:"is_ad,omitempty"`
	// contains filtered or unexported fields
}

func (*Result) Descriptor deprecated

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

Deprecated: Use Result.ProtoReflect.Descriptor instead.

func (*Result) GetIsAd

func (x *Result) GetIsAd() bool

func (*Result) GetSnippets

func (x *Result) GetSnippets() []string

func (*Result) GetTitle

func (x *Result) GetTitle() string

func (*Result) GetUrl

func (x *Result) GetUrl() string

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) ProtoReflect

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

func (*Result) Reset

func (x *Result) Reset()

func (*Result) String

func (x *Result) String() string

type SearchRequest

type SearchRequest struct {
	Query         string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
	PageNumber    int32  `protobuf:"varint,2,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"`
	ResultPerPage int32  `protobuf:"varint,3,opt,name=result_per_page,json=resultPerPage,proto3" json:"result_per_page,omitempty"`
	// contains filtered or unexported fields
}

func (*SearchRequest) Descriptor deprecated

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

Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.

func (*SearchRequest) GetPageNumber

func (x *SearchRequest) GetPageNumber() int32

func (*SearchRequest) GetQuery

func (x *SearchRequest) GetQuery() string

func (*SearchRequest) GetResultPerPage

func (x *SearchRequest) GetResultPerPage() int32

func (*SearchRequest) ProtoMessage

func (*SearchRequest) ProtoMessage()

func (*SearchRequest) ProtoReflect

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

func (*SearchRequest) Reset

func (x *SearchRequest) Reset()

func (*SearchRequest) String

func (x *SearchRequest) String() string

type SearchResponse

type SearchResponse struct {
	Results []*Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
	// contains filtered or unexported fields
}

func (*SearchResponse) Descriptor deprecated

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

Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.

func (*SearchResponse) GetResults

func (x *SearchResponse) GetResults() []*Result

func (*SearchResponse) ProtoMessage

func (*SearchResponse) ProtoMessage()

func (*SearchResponse) ProtoReflect

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

func (*SearchResponse) Reset

func (x *SearchResponse) Reset()

func (*SearchResponse) String

func (x *SearchResponse) String() string

type SearchService

type SearchService interface {
	Search(context.Context, *SearchRequest) (*SearchResponse, error)

	Index(context.Context, *IndexRequest) (*IndexResponse, error)
}

func NewSearchServiceJSONClient

func NewSearchServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) SearchService

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

func NewSearchServiceProtobufClient

func NewSearchServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) SearchService

NewSearchServiceProtobufClient creates a Protobuf client that implements the SearchService 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 NewQuirksServer

func NewQuirksServer(svc Quirks, opts ...interface{}) TwirpServer

NewQuirksServer 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).

func NewSearchServiceServer

func NewSearchServiceServer(svc SearchService, opts ...interface{}) TwirpServer

NewSearchServiceServer 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 TypesRequest

type TypesRequest struct {
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Bool      bool                   `protobuf:"varint,2,opt,name=bool,proto3" json:"bool,omitempty"`
	// contains filtered or unexported fields
}

func (*TypesRequest) Descriptor deprecated

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

Deprecated: Use TypesRequest.ProtoReflect.Descriptor instead.

func (*TypesRequest) GetBool

func (x *TypesRequest) GetBool() bool

func (*TypesRequest) GetTimestamp

func (x *TypesRequest) GetTimestamp() *timestamppb.Timestamp

func (*TypesRequest) ProtoMessage

func (*TypesRequest) ProtoMessage()

func (*TypesRequest) ProtoReflect

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

func (*TypesRequest) Reset

func (x *TypesRequest) Reset()

func (*TypesRequest) String

func (x *TypesRequest) String() string

type Void

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

func (*Void) Descriptor deprecated

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

Deprecated: Use Void.ProtoReflect.Descriptor instead.

func (*Void) ProtoMessage

func (*Void) ProtoMessage()

func (*Void) ProtoReflect

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

func (*Void) Reset

func (x *Void) Reset()

func (*Void) String

func (x *Void) String() string

Jump to

Keyboard shortcuts

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