Documentation ¶
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type DefineWordsRequest
- func (*DefineWordsRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DefineWordsRequest) GetAnagrams() bool
- func (x *DefineWordsRequest) GetDefinitions() bool
- func (x *DefineWordsRequest) GetLexicon() string
- func (x *DefineWordsRequest) GetWords() []string
- func (*DefineWordsRequest) ProtoMessage()
- func (x *DefineWordsRequest) ProtoReflect() protoreflect.Message
- func (x *DefineWordsRequest) Reset()
- func (x *DefineWordsRequest) String() string
- type DefineWordsResponse
- func (*DefineWordsResponse) Descriptor() ([]byte, []int)deprecated
- func (x *DefineWordsResponse) GetResults() map[string]*DefineWordsResult
- func (*DefineWordsResponse) ProtoMessage()
- func (x *DefineWordsResponse) ProtoReflect() protoreflect.Message
- func (x *DefineWordsResponse) Reset()
- func (x *DefineWordsResponse) String() string
- type DefineWordsResult
- func (*DefineWordsResult) Descriptor() ([]byte, []int)deprecated
- func (x *DefineWordsResult) GetD() string
- func (x *DefineWordsResult) GetV() bool
- func (*DefineWordsResult) ProtoMessage()
- func (x *DefineWordsResult) ProtoReflect() protoreflect.Message
- func (x *DefineWordsResult) Reset()
- func (x *DefineWordsResult) String() string
- type HTTPClient
- type TwirpServer
- type WordService
Constants ¶
const WordServicePathPrefix = "/twirp/word_service.WordService/"
WordServicePathPrefix 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_api_proto_word_service_word_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 DefineWordsRequest ¶
type DefineWordsRequest struct { Lexicon string `protobuf:"bytes,1,opt,name=lexicon,proto3" json:"lexicon,omitempty"` Words []string `protobuf:"bytes,2,rep,name=words,proto3" json:"words,omitempty"` Definitions bool `protobuf:"varint,3,opt,name=definitions,proto3" json:"definitions,omitempty"` // pass true to retrieve definitions Anagrams bool `protobuf:"varint,4,opt,name=anagrams,proto3" json:"anagrams,omitempty"` // contains filtered or unexported fields }
func (*DefineWordsRequest) Descriptor
deprecated
func (*DefineWordsRequest) Descriptor() ([]byte, []int)
Deprecated: Use DefineWordsRequest.ProtoReflect.Descriptor instead.
func (*DefineWordsRequest) GetAnagrams ¶
func (x *DefineWordsRequest) GetAnagrams() bool
func (*DefineWordsRequest) GetDefinitions ¶
func (x *DefineWordsRequest) GetDefinitions() bool
func (*DefineWordsRequest) GetLexicon ¶
func (x *DefineWordsRequest) GetLexicon() string
func (*DefineWordsRequest) GetWords ¶
func (x *DefineWordsRequest) GetWords() []string
func (*DefineWordsRequest) ProtoMessage ¶
func (*DefineWordsRequest) ProtoMessage()
func (*DefineWordsRequest) ProtoReflect ¶
func (x *DefineWordsRequest) ProtoReflect() protoreflect.Message
func (*DefineWordsRequest) Reset ¶
func (x *DefineWordsRequest) Reset()
func (*DefineWordsRequest) String ¶
func (x *DefineWordsRequest) String() string
type DefineWordsResponse ¶
type DefineWordsResponse struct { Results map[string]*DefineWordsResult `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
func (*DefineWordsResponse) Descriptor
deprecated
func (*DefineWordsResponse) Descriptor() ([]byte, []int)
Deprecated: Use DefineWordsResponse.ProtoReflect.Descriptor instead.
func (*DefineWordsResponse) GetResults ¶
func (x *DefineWordsResponse) GetResults() map[string]*DefineWordsResult
func (*DefineWordsResponse) ProtoMessage ¶
func (*DefineWordsResponse) ProtoMessage()
func (*DefineWordsResponse) ProtoReflect ¶
func (x *DefineWordsResponse) ProtoReflect() protoreflect.Message
func (*DefineWordsResponse) Reset ¶
func (x *DefineWordsResponse) Reset()
func (*DefineWordsResponse) String ¶
func (x *DefineWordsResponse) String() string
type DefineWordsResult ¶
type DefineWordsResult struct { D string `protobuf:"bytes,1,opt,name=d,proto3" json:"d,omitempty"` // definitions, not "" iff (valid and requesting definitions) V bool `protobuf:"varint,2,opt,name=v,proto3" json:"v,omitempty"` // true iff valid // contains filtered or unexported fields }
func (*DefineWordsResult) Descriptor
deprecated
func (*DefineWordsResult) Descriptor() ([]byte, []int)
Deprecated: Use DefineWordsResult.ProtoReflect.Descriptor instead.
func (*DefineWordsResult) GetD ¶
func (x *DefineWordsResult) GetD() string
func (*DefineWordsResult) GetV ¶
func (x *DefineWordsResult) GetV() bool
func (*DefineWordsResult) ProtoMessage ¶
func (*DefineWordsResult) ProtoMessage()
func (*DefineWordsResult) ProtoReflect ¶
func (x *DefineWordsResult) ProtoReflect() protoreflect.Message
func (*DefineWordsResult) Reset ¶
func (x *DefineWordsResult) Reset()
func (*DefineWordsResult) String ¶
func (x *DefineWordsResult) 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 NewWordServiceServer ¶
func NewWordServiceServer(svc WordService, opts ...interface{}) TwirpServer
NewWordServiceServer 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 WordService ¶
type WordService interface {
DefineWords(context.Context, *DefineWordsRequest) (*DefineWordsResponse, error)
}
func NewWordServiceJSONClient ¶
func NewWordServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) WordService
NewWordServiceJSONClient creates a JSON client that implements the WordService interface. It communicates using JSON and can be configured with a custom HTTPClient.
func NewWordServiceProtobufClient ¶
func NewWordServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) WordService
NewWordServiceProtobufClient creates a Protobuf client that implements the WordService interface. It communicates using Protobuf and can be configured with a custom HTTPClient.