spell

package
v0.17.3-pre1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CheckPathPrefix = "/twirp/elephant.spell.Check/"

CheckPathPrefix 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 DictionariesPathPrefix = "/twirp/elephant.spell.Dictionaries/"

DictionariesPathPrefix 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_spell_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 Check

type Check interface {
	// Text spellchecks a text and returns the misspelled words or phrases.
	Text(context.Context, *TextRequest) (*TextResponse, error)
}

Check content for spelling errors.

func NewCheckJSONClient

func NewCheckJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Check

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

func NewCheckProtobufClient

func NewCheckProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Check

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

type CustomDictionary

type CustomDictionary struct {

	// Language the dictionary is for.
	Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
	// EntryCount for the dictionary.
	EntryCount int64 `protobuf:"varint,2,opt,name=entry_count,json=entryCount,proto3" json:"entry_count,omitempty"`
	// contains filtered or unexported fields
}

func (*CustomDictionary) Descriptor deprecated

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

Deprecated: Use CustomDictionary.ProtoReflect.Descriptor instead.

func (*CustomDictionary) GetEntryCount

func (x *CustomDictionary) GetEntryCount() int64

func (*CustomDictionary) GetLanguage

func (x *CustomDictionary) GetLanguage() string

func (*CustomDictionary) ProtoMessage

func (*CustomDictionary) ProtoMessage()

func (*CustomDictionary) ProtoReflect

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

func (*CustomDictionary) Reset

func (x *CustomDictionary) Reset()

func (*CustomDictionary) String

func (x *CustomDictionary) String() string

type CustomEntry

type CustomEntry struct {

	// Language the entry is for.
	Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
	// Text is the word (or phrase) itself.
	Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	// Status of the entry, this is used for moderation.
	Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
	// Description of the entry.
	Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
	// CommonMistakes when writing the word or phrase. This is used to pre-filter
	// text that is spell-checked.
	CommonMistakes []string `protobuf:"bytes,5,rep,name=common_mistakes,json=commonMistakes,proto3" json:"common_mistakes,omitempty"`
	// contains filtered or unexported fields
}

func (*CustomEntry) Descriptor deprecated

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

Deprecated: Use CustomEntry.ProtoReflect.Descriptor instead.

func (*CustomEntry) GetCommonMistakes

func (x *CustomEntry) GetCommonMistakes() []string

func (*CustomEntry) GetDescription

func (x *CustomEntry) GetDescription() string

func (*CustomEntry) GetLanguage

func (x *CustomEntry) GetLanguage() string

func (*CustomEntry) GetStatus

func (x *CustomEntry) GetStatus() string

func (*CustomEntry) GetText

func (x *CustomEntry) GetText() string

func (*CustomEntry) ProtoMessage

func (*CustomEntry) ProtoMessage()

func (*CustomEntry) ProtoReflect

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

func (*CustomEntry) Reset

func (x *CustomEntry) Reset()

func (*CustomEntry) String

func (x *CustomEntry) String() string

type DeleteEntryRequest

type DeleteEntryRequest struct {

	// Language the entry is for.
	Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
	// Text is the word or phrase to delete.
	Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	// contains filtered or unexported fields
}

func (*DeleteEntryRequest) Descriptor deprecated

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

Deprecated: Use DeleteEntryRequest.ProtoReflect.Descriptor instead.

func (*DeleteEntryRequest) GetLanguage

func (x *DeleteEntryRequest) GetLanguage() string

func (*DeleteEntryRequest) GetText

func (x *DeleteEntryRequest) GetText() string

func (*DeleteEntryRequest) ProtoMessage

func (*DeleteEntryRequest) ProtoMessage()

func (*DeleteEntryRequest) ProtoReflect

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

func (*DeleteEntryRequest) Reset

func (x *DeleteEntryRequest) Reset()

func (*DeleteEntryRequest) String

func (x *DeleteEntryRequest) String() string

type DeleteEntryResponse

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

func (*DeleteEntryResponse) Descriptor deprecated

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

Deprecated: Use DeleteEntryResponse.ProtoReflect.Descriptor instead.

func (*DeleteEntryResponse) ProtoMessage

func (*DeleteEntryResponse) ProtoMessage()

func (*DeleteEntryResponse) ProtoReflect

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

func (*DeleteEntryResponse) Reset

func (x *DeleteEntryResponse) Reset()

func (*DeleteEntryResponse) String

func (x *DeleteEntryResponse) String() string

type Dictionaries

type Dictionaries interface {
	// ListDictionaries lists the currently available custom dictionaries.
	ListDictionaries(context.Context, *ListDictionariesRequest) (*ListDictionariesResponse, error)

	// ListEntries lists entries in the custom dictionaries.
	ListEntries(context.Context, *ListEntriesRequest) (*ListEntriesResponse, error)

	// GetEntry returns the details of a custom word or phrase.
	GetEntry(context.Context, *GetEntryRequest) (*GetEntryResponse, error)

	// SetEntry is used to add or update custom dictionary entries.
	SetEntry(context.Context, *SetEntryRequest) (*SetEntryResponse, error)

	// DeleteEntry is used to remove an entry.
	DeleteEntry(context.Context, *DeleteEntryRequest) (*DeleteEntryResponse, error)
}

Dictionaries is used to manage custom dictionary entries. Custom dictionaries can be used to add both words and phrases.

func NewDictionariesJSONClient

func NewDictionariesJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Dictionaries

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

func NewDictionariesProtobufClient

func NewDictionariesProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Dictionaries

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

type GetEntryRequest

type GetEntryRequest struct {

	// Language the entry is for.
	Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
	// Text is the word or phrase to get the entry for.
	Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	// contains filtered or unexported fields
}

func (*GetEntryRequest) Descriptor deprecated

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

Deprecated: Use GetEntryRequest.ProtoReflect.Descriptor instead.

func (*GetEntryRequest) GetLanguage

func (x *GetEntryRequest) GetLanguage() string

func (*GetEntryRequest) GetText

func (x *GetEntryRequest) GetText() string

func (*GetEntryRequest) ProtoMessage

func (*GetEntryRequest) ProtoMessage()

func (*GetEntryRequest) ProtoReflect

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

func (*GetEntryRequest) Reset

func (x *GetEntryRequest) Reset()

func (*GetEntryRequest) String

func (x *GetEntryRequest) String() string

type GetEntryResponse

type GetEntryResponse struct {

	// Entry information.
	Entry *CustomEntry `protobuf:"bytes,1,opt,name=entry,proto3" json:"entry,omitempty"`
	// contains filtered or unexported fields
}

func (*GetEntryResponse) Descriptor deprecated

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

Deprecated: Use GetEntryResponse.ProtoReflect.Descriptor instead.

func (*GetEntryResponse) GetEntry

func (x *GetEntryResponse) GetEntry() *CustomEntry

func (*GetEntryResponse) ProtoMessage

func (*GetEntryResponse) ProtoMessage()

func (*GetEntryResponse) ProtoReflect

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

func (*GetEntryResponse) Reset

func (x *GetEntryResponse) Reset()

func (*GetEntryResponse) String

func (x *GetEntryResponse) 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 ListDictionariesRequest

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

func (*ListDictionariesRequest) Descriptor deprecated

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

Deprecated: Use ListDictionariesRequest.ProtoReflect.Descriptor instead.

func (*ListDictionariesRequest) ProtoMessage

func (*ListDictionariesRequest) ProtoMessage()

func (*ListDictionariesRequest) ProtoReflect

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

func (*ListDictionariesRequest) Reset

func (x *ListDictionariesRequest) Reset()

func (*ListDictionariesRequest) String

func (x *ListDictionariesRequest) String() string

type ListDictionariesResponse

type ListDictionariesResponse struct {
	Dictionaries []*CustomDictionary `protobuf:"bytes,1,rep,name=dictionaries,proto3" json:"dictionaries,omitempty"`
	// contains filtered or unexported fields
}

func (*ListDictionariesResponse) Descriptor deprecated

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

Deprecated: Use ListDictionariesResponse.ProtoReflect.Descriptor instead.

func (*ListDictionariesResponse) GetDictionaries

func (x *ListDictionariesResponse) GetDictionaries() []*CustomDictionary

func (*ListDictionariesResponse) ProtoMessage

func (*ListDictionariesResponse) ProtoMessage()

func (*ListDictionariesResponse) ProtoReflect

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

func (*ListDictionariesResponse) Reset

func (x *ListDictionariesResponse) Reset()

func (*ListDictionariesResponse) String

func (x *ListDictionariesResponse) String() string

type ListEntriesRequest

type ListEntriesRequest struct {

	// Language to list entries for.
	Language string `protobuf:"bytes,1,opt,name=language,proto3" json:"language,omitempty"`
	// Page to return.
	Page int64 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"`
	// Prefix to filter entries by.
	Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"`
	// Status to filter entries by
	Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*ListEntriesRequest) Descriptor deprecated

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

Deprecated: Use ListEntriesRequest.ProtoReflect.Descriptor instead.

func (*ListEntriesRequest) GetLanguage

func (x *ListEntriesRequest) GetLanguage() string

func (*ListEntriesRequest) GetPage

func (x *ListEntriesRequest) GetPage() int64

func (*ListEntriesRequest) GetPrefix

func (x *ListEntriesRequest) GetPrefix() string

func (*ListEntriesRequest) GetStatus

func (x *ListEntriesRequest) GetStatus() string

func (*ListEntriesRequest) ProtoMessage

func (*ListEntriesRequest) ProtoMessage()

func (*ListEntriesRequest) ProtoReflect

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

func (*ListEntriesRequest) Reset

func (x *ListEntriesRequest) Reset()

func (*ListEntriesRequest) String

func (x *ListEntriesRequest) String() string

type ListEntriesResponse

type ListEntriesResponse struct {
	Entries []*CustomEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

func (*ListEntriesResponse) Descriptor deprecated

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

Deprecated: Use ListEntriesResponse.ProtoReflect.Descriptor instead.

func (*ListEntriesResponse) GetEntries

func (x *ListEntriesResponse) GetEntries() []*CustomEntry

func (*ListEntriesResponse) ProtoMessage

func (*ListEntriesResponse) ProtoMessage()

func (*ListEntriesResponse) ProtoReflect

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

func (*ListEntriesResponse) Reset

func (x *ListEntriesResponse) Reset()

func (*ListEntriesResponse) String

func (x *ListEntriesResponse) String() string

type Misspelled added in v0.17.2

type Misspelled struct {
	Entries []*MisspelledEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

func (*Misspelled) Descriptor deprecated added in v0.17.2

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

Deprecated: Use Misspelled.ProtoReflect.Descriptor instead.

func (*Misspelled) GetEntries added in v0.17.2

func (x *Misspelled) GetEntries() []*MisspelledEntry

func (*Misspelled) ProtoMessage added in v0.17.2

func (*Misspelled) ProtoMessage()

func (*Misspelled) ProtoReflect added in v0.17.2

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

func (*Misspelled) Reset added in v0.17.2

func (x *Misspelled) Reset()

func (*Misspelled) String added in v0.17.2

func (x *Misspelled) String() string

type MisspelledEntry

type MisspelledEntry struct {

	// Text that was used in the source text.
	Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	// Suggestions for replacements.
	Suggestions []*Suggestion `protobuf:"bytes,2,rep,name=suggestions,proto3" json:"suggestions,omitempty"`
	// contains filtered or unexported fields
}

func (*MisspelledEntry) Descriptor deprecated

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

Deprecated: Use MisspelledEntry.ProtoReflect.Descriptor instead.

func (*MisspelledEntry) GetSuggestions

func (x *MisspelledEntry) GetSuggestions() []*Suggestion

func (*MisspelledEntry) GetText

func (x *MisspelledEntry) GetText() string

func (*MisspelledEntry) ProtoMessage

func (*MisspelledEntry) ProtoMessage()

func (*MisspelledEntry) ProtoReflect

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

func (*MisspelledEntry) Reset

func (x *MisspelledEntry) Reset()

func (*MisspelledEntry) String

func (x *MisspelledEntry) String() string

type SetEntryRequest

type SetEntryRequest struct {

	// Entry to set.
	Entry *CustomEntry `protobuf:"bytes,1,opt,name=entry,proto3" json:"entry,omitempty"`
	// contains filtered or unexported fields
}

func (*SetEntryRequest) Descriptor deprecated

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

Deprecated: Use SetEntryRequest.ProtoReflect.Descriptor instead.

func (*SetEntryRequest) GetEntry

func (x *SetEntryRequest) GetEntry() *CustomEntry

func (*SetEntryRequest) ProtoMessage

func (*SetEntryRequest) ProtoMessage()

func (*SetEntryRequest) ProtoReflect

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

func (*SetEntryRequest) Reset

func (x *SetEntryRequest) Reset()

func (*SetEntryRequest) String

func (x *SetEntryRequest) String() string

type SetEntryResponse

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

func (*SetEntryResponse) Descriptor deprecated

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

Deprecated: Use SetEntryResponse.ProtoReflect.Descriptor instead.

func (*SetEntryResponse) ProtoMessage

func (*SetEntryResponse) ProtoMessage()

func (*SetEntryResponse) ProtoReflect

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

func (*SetEntryResponse) Reset

func (x *SetEntryResponse) Reset()

func (*SetEntryResponse) String

func (x *SetEntryResponse) String() string

type Suggestion

type Suggestion struct {
	Text        string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// contains filtered or unexported fields
}

func (*Suggestion) Descriptor deprecated

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

Deprecated: Use Suggestion.ProtoReflect.Descriptor instead.

func (*Suggestion) GetDescription

func (x *Suggestion) GetDescription() string

func (*Suggestion) GetText

func (x *Suggestion) GetText() string

func (*Suggestion) ProtoMessage

func (*Suggestion) ProtoMessage()

func (*Suggestion) ProtoReflect

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

func (*Suggestion) Reset

func (x *Suggestion) Reset()

func (*Suggestion) String

func (x *Suggestion) String() string

type TextRequest

type TextRequest struct {

	// Text to spellcheck.
	Text []string `protobuf:"bytes,1,rep,name=text,proto3" json:"text,omitempty"`
	// Language to check the text for.
	Language string `protobuf:"bytes,2,opt,name=language,proto3" json:"language,omitempty"`
	// contains filtered or unexported fields
}

func (*TextRequest) Descriptor deprecated

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

Deprecated: Use TextRequest.ProtoReflect.Descriptor instead.

func (*TextRequest) GetLanguage

func (x *TextRequest) GetLanguage() string

func (*TextRequest) GetText

func (x *TextRequest) GetText() []string

func (*TextRequest) ProtoMessage

func (*TextRequest) ProtoMessage()

func (*TextRequest) ProtoReflect

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

func (*TextRequest) Reset

func (x *TextRequest) Reset()

func (*TextRequest) String

func (x *TextRequest) String() string

type TextResponse

type TextResponse struct {
	Misspelled []*Misspelled `protobuf:"bytes,1,rep,name=misspelled,proto3" json:"misspelled,omitempty"`
	// contains filtered or unexported fields
}

func (*TextResponse) Descriptor deprecated

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

Deprecated: Use TextResponse.ProtoReflect.Descriptor instead.

func (*TextResponse) GetMisspelled

func (x *TextResponse) GetMisspelled() []*Misspelled

func (*TextResponse) ProtoMessage

func (*TextResponse) ProtoMessage()

func (*TextResponse) ProtoReflect

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

func (*TextResponse) Reset

func (x *TextResponse) Reset()

func (*TextResponse) String

func (x *TextResponse) 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 NewCheckServer

func NewCheckServer(svc Check, opts ...interface{}) TwirpServer

NewCheckServer 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 NewDictionariesServer

func NewDictionariesServer(svc Dictionaries, opts ...interface{}) TwirpServer

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

Jump to

Keyboard shortcuts

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