Documentation
¶
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type CreatePasteRequest
- func (*CreatePasteRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreatePasteRequest) GetContent() string
- func (x *CreatePasteRequest) GetHeaders() map[string]string
- func (x *CreatePasteRequest) GetTitle() string
- func (x *CreatePasteRequest) GetTtl() uint64
- func (*CreatePasteRequest) ProtoMessage()
- func (x *CreatePasteRequest) ProtoReflect() protoreflect.Message
- func (x *CreatePasteRequest) Reset()
- func (x *CreatePasteRequest) String() string
- type CreatePasteResponse
- func (*CreatePasteResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreatePasteResponse) GetCreatedAt() uint64
- func (x *CreatePasteResponse) GetUuid() string
- func (*CreatePasteResponse) ProtoMessage()
- func (x *CreatePasteResponse) ProtoReflect() protoreflect.Message
- func (x *CreatePasteResponse) Reset()
- func (x *CreatePasteResponse) String() string
- type GetPasteRequest
- type GetPasteResponse
- func (*GetPasteResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetPasteResponse) GetContent() string
- func (x *GetPasteResponse) GetHeaders() map[string]string
- func (x *GetPasteResponse) GetTitle() string
- func (*GetPasteResponse) ProtoMessage()
- func (x *GetPasteResponse) ProtoReflect() protoreflect.Message
- func (x *GetPasteResponse) Reset()
- func (x *GetPasteResponse) String() string
- type HTTPClient
- type Paster
- type TwirpServer
Constants ¶
const PasterPathPrefix = "/twirp/pasteit.Paster/"
PasterPathPrefix 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_protobuf_pasteit_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 CreatePasteRequest ¶
type CreatePasteRequest struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` Headers map[string]string `` /* 155-byte string literal not displayed */ Ttl uint64 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"` // contains filtered or unexported fields }
func (*CreatePasteRequest) Descriptor
deprecated
func (*CreatePasteRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreatePasteRequest.ProtoReflect.Descriptor instead.
func (*CreatePasteRequest) GetContent ¶
func (x *CreatePasteRequest) GetContent() string
func (*CreatePasteRequest) GetHeaders ¶
func (x *CreatePasteRequest) GetHeaders() map[string]string
func (*CreatePasteRequest) GetTitle ¶
func (x *CreatePasteRequest) GetTitle() string
func (*CreatePasteRequest) GetTtl ¶
func (x *CreatePasteRequest) GetTtl() uint64
func (*CreatePasteRequest) ProtoMessage ¶
func (*CreatePasteRequest) ProtoMessage()
func (*CreatePasteRequest) ProtoReflect ¶
func (x *CreatePasteRequest) ProtoReflect() protoreflect.Message
func (*CreatePasteRequest) Reset ¶
func (x *CreatePasteRequest) Reset()
func (*CreatePasteRequest) String ¶
func (x *CreatePasteRequest) String() string
type CreatePasteResponse ¶
type CreatePasteResponse struct { Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` CreatedAt uint64 `protobuf:"varint,2,opt,name=createdAt,proto3" json:"createdAt,omitempty"` // contains filtered or unexported fields }
func (*CreatePasteResponse) Descriptor
deprecated
func (*CreatePasteResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreatePasteResponse.ProtoReflect.Descriptor instead.
func (*CreatePasteResponse) GetCreatedAt ¶
func (x *CreatePasteResponse) GetCreatedAt() uint64
func (*CreatePasteResponse) GetUuid ¶
func (x *CreatePasteResponse) GetUuid() string
func (*CreatePasteResponse) ProtoMessage ¶
func (*CreatePasteResponse) ProtoMessage()
func (*CreatePasteResponse) ProtoReflect ¶
func (x *CreatePasteResponse) ProtoReflect() protoreflect.Message
func (*CreatePasteResponse) Reset ¶
func (x *CreatePasteResponse) Reset()
func (*CreatePasteResponse) String ¶
func (x *CreatePasteResponse) String() string
type GetPasteRequest ¶
type GetPasteRequest struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*GetPasteRequest) Descriptor
deprecated
func (*GetPasteRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetPasteRequest.ProtoReflect.Descriptor instead.
func (*GetPasteRequest) GetId ¶
func (x *GetPasteRequest) GetId() string
func (*GetPasteRequest) ProtoMessage ¶
func (*GetPasteRequest) ProtoMessage()
func (*GetPasteRequest) ProtoReflect ¶
func (x *GetPasteRequest) ProtoReflect() protoreflect.Message
func (*GetPasteRequest) Reset ¶
func (x *GetPasteRequest) Reset()
func (*GetPasteRequest) String ¶
func (x *GetPasteRequest) String() string
type GetPasteResponse ¶
type GetPasteResponse struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` Headers map[string]string `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
func (*GetPasteResponse) Descriptor
deprecated
func (*GetPasteResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetPasteResponse.ProtoReflect.Descriptor instead.
func (*GetPasteResponse) GetContent ¶
func (x *GetPasteResponse) GetContent() string
func (*GetPasteResponse) GetHeaders ¶
func (x *GetPasteResponse) GetHeaders() map[string]string
func (*GetPasteResponse) GetTitle ¶
func (x *GetPasteResponse) GetTitle() string
func (*GetPasteResponse) ProtoMessage ¶
func (*GetPasteResponse) ProtoMessage()
func (*GetPasteResponse) ProtoReflect ¶
func (x *GetPasteResponse) ProtoReflect() protoreflect.Message
func (*GetPasteResponse) Reset ¶
func (x *GetPasteResponse) Reset()
func (*GetPasteResponse) String ¶
func (x *GetPasteResponse) 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 Paster ¶
type Paster interface { CreatePaste(context.Context, *CreatePasteRequest) (*CreatePasteResponse, error) GetPaste(context.Context, *GetPasteRequest) (*GetPasteResponse, error) }
Paster service does something
func NewPasterJSONClient ¶
func NewPasterJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Paster
NewPasterJSONClient creates a JSON client that implements the Paster interface. It communicates using JSON and can be configured with a custom HTTPClient.
func NewPasterProtobufClient ¶
func NewPasterProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Paster
NewPasterProtobufClient creates a Protobuf client that implements the Paster 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 NewPasterServer ¶
func NewPasterServer(svc Paster, opts ...interface{}) TwirpServer
NewPasterServer 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).