api

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const APIPathPrefix = "/twirp/lure.API/"

APIPathPrefix 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 (
	SORT_BY_name = map[int32]string{
		0: "UNSORTED",
		1: "NAME",
		2: "REPOSITORY",
		3: "VERSION",
	}
	SORT_BY_value = map[string]int32{
		"UNSORTED":   0,
		"NAME":       1,
		"REPOSITORY": 2,
		"VERSION":    3,
	}
)

Enum value maps for SORT_BY.

View Source
var (
	FILTER_TYPE_name = map[int32]string{
		0: "NO_FILTER",
		1: "IN_REPOSITORY",
		2: "SUPPORTS_ARCH",
	}
	FILTER_TYPE_value = map[string]int32{
		"NO_FILTER":     0,
		"IN_REPOSITORY": 1,
		"SUPPORTS_ARCH": 2,
	}
)

Enum value maps for FILTER_TYPE.

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 API

type API interface {
	// Search searches through LURE packages in the database
	Search(context.Context, *SearchRequest) (*SearchResponse, error)

	// GetPkg gets a single LURE package from the database
	GetPkg(context.Context, *GetPackageRequest) (*Package, error)

	// GetBuildScript returns the build script for the given package
	GetBuildScript(context.Context, *GetBuildScriptRequest) (*GetBuildScriptResponse, error)
}

Web is the LURE Web service

func NewAPIJSONClient

func NewAPIJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) API

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

func NewAPIProtobufClient

func NewAPIProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) API

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

type FILTER_TYPE

type FILTER_TYPE int32

FILTER_TYPE represents possible filters for packages

const (
	FILTER_TYPE_NO_FILTER     FILTER_TYPE = 0
	FILTER_TYPE_IN_REPOSITORY FILTER_TYPE = 1
	FILTER_TYPE_SUPPORTS_ARCH FILTER_TYPE = 2
)

func (FILTER_TYPE) Descriptor

func (FILTER_TYPE) Enum

func (x FILTER_TYPE) Enum() *FILTER_TYPE

func (FILTER_TYPE) EnumDescriptor deprecated

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

Deprecated: Use FILTER_TYPE.Descriptor instead.

func (FILTER_TYPE) Number

func (x FILTER_TYPE) Number() protoreflect.EnumNumber

func (FILTER_TYPE) String

func (x FILTER_TYPE) String() string

func (FILTER_TYPE) Type

type GetBuildScriptRequest

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

func (*GetBuildScriptRequest) Descriptor deprecated

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

Deprecated: Use GetBuildScriptRequest.ProtoReflect.Descriptor instead.

func (*GetBuildScriptRequest) GetName

func (x *GetBuildScriptRequest) GetName() string

func (*GetBuildScriptRequest) GetRepository

func (x *GetBuildScriptRequest) GetRepository() string

func (*GetBuildScriptRequest) ProtoMessage

func (*GetBuildScriptRequest) ProtoMessage()

func (*GetBuildScriptRequest) ProtoReflect

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

func (*GetBuildScriptRequest) Reset

func (x *GetBuildScriptRequest) Reset()

func (*GetBuildScriptRequest) String

func (x *GetBuildScriptRequest) String() string

type GetBuildScriptResponse

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

func (*GetBuildScriptResponse) Descriptor deprecated

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

Deprecated: Use GetBuildScriptResponse.ProtoReflect.Descriptor instead.

func (*GetBuildScriptResponse) GetScript

func (x *GetBuildScriptResponse) GetScript() string

func (*GetBuildScriptResponse) ProtoMessage

func (*GetBuildScriptResponse) ProtoMessage()

func (*GetBuildScriptResponse) ProtoReflect

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

func (*GetBuildScriptResponse) Reset

func (x *GetBuildScriptResponse) Reset()

func (*GetBuildScriptResponse) String

func (x *GetBuildScriptResponse) String() string

type GetPackageRequest

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

func (*GetPackageRequest) Descriptor deprecated

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

Deprecated: Use GetPackageRequest.ProtoReflect.Descriptor instead.

func (*GetPackageRequest) GetName

func (x *GetPackageRequest) GetName() string

func (*GetPackageRequest) GetRepository

func (x *GetPackageRequest) GetRepository() string

func (*GetPackageRequest) ProtoMessage

func (*GetPackageRequest) ProtoMessage()

func (*GetPackageRequest) ProtoReflect

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

func (*GetPackageRequest) Reset

func (x *GetPackageRequest) Reset()

func (*GetPackageRequest) String

func (x *GetPackageRequest) 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 Package

type Package struct {
	Name          string                 `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Repository    string                 `protobuf:"bytes,2,opt,name=repository,proto3" json:"repository,omitempty"`
	Version       string                 `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
	Release       int64                  `protobuf:"varint,4,opt,name=release,proto3" json:"release,omitempty"`
	Epoch         *int64                 `protobuf:"varint,5,opt,name=epoch,proto3,oneof" json:"epoch,omitempty"`
	Description   *string                `protobuf:"bytes,6,opt,name=description,proto3,oneof" json:"description,omitempty"`
	Homepage      *string                `protobuf:"bytes,7,opt,name=homepage,proto3,oneof" json:"homepage,omitempty"`
	Maintainer    *string                `protobuf:"bytes,8,opt,name=maintainer,proto3,oneof" json:"maintainer,omitempty"`
	Architectures []string               `protobuf:"bytes,9,rep,name=architectures,proto3" json:"architectures,omitempty"`
	Licenses      []string               `protobuf:"bytes,10,rep,name=licenses,proto3" json:"licenses,omitempty"`
	Provides      []string               `protobuf:"bytes,11,rep,name=provides,proto3" json:"provides,omitempty"`
	Conflicts     []string               `protobuf:"bytes,12,rep,name=conflicts,proto3" json:"conflicts,omitempty"`
	Replaces      []string               `protobuf:"bytes,13,rep,name=replaces,proto3" json:"replaces,omitempty"`
	Depends       map[string]*StringList `` /* 156-byte string literal not displayed */
	BuildDepends  map[string]*StringList `` /* 186-byte string literal not displayed */
	// contains filtered or unexported fields
}

Package represents a LURE package

func (*Package) Descriptor deprecated

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

Deprecated: Use Package.ProtoReflect.Descriptor instead.

func (*Package) GetArchitectures

func (x *Package) GetArchitectures() []string

func (*Package) GetBuildDepends

func (x *Package) GetBuildDepends() map[string]*StringList

func (*Package) GetConflicts

func (x *Package) GetConflicts() []string

func (*Package) GetDepends

func (x *Package) GetDepends() map[string]*StringList

func (*Package) GetDescription

func (x *Package) GetDescription() string

func (*Package) GetEpoch

func (x *Package) GetEpoch() int64

func (*Package) GetHomepage

func (x *Package) GetHomepage() string

func (*Package) GetLicenses

func (x *Package) GetLicenses() []string

func (*Package) GetMaintainer

func (x *Package) GetMaintainer() string

func (*Package) GetName

func (x *Package) GetName() string

func (*Package) GetProvides

func (x *Package) GetProvides() []string

func (*Package) GetRelease

func (x *Package) GetRelease() int64

func (*Package) GetReplaces

func (x *Package) GetReplaces() []string

func (*Package) GetRepository

func (x *Package) GetRepository() string

func (*Package) GetVersion

func (x *Package) GetVersion() string

func (*Package) ProtoMessage

func (*Package) ProtoMessage()

func (*Package) ProtoReflect

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

func (*Package) Reset

func (x *Package) Reset()

func (*Package) String

func (x *Package) String() string

type SORT_BY

type SORT_BY int32

SORT_BY represents possible things to sort packages by

const (
	SORT_BY_UNSORTED   SORT_BY = 0
	SORT_BY_NAME       SORT_BY = 1
	SORT_BY_REPOSITORY SORT_BY = 2
	SORT_BY_VERSION    SORT_BY = 3
)

func (SORT_BY) Descriptor

func (SORT_BY) Descriptor() protoreflect.EnumDescriptor

func (SORT_BY) Enum

func (x SORT_BY) Enum() *SORT_BY

func (SORT_BY) EnumDescriptor deprecated

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

Deprecated: Use SORT_BY.Descriptor instead.

func (SORT_BY) Number

func (x SORT_BY) Number() protoreflect.EnumNumber

func (SORT_BY) String

func (x SORT_BY) String() string

func (SORT_BY) Type

func (SORT_BY) Type() protoreflect.EnumType

type SearchRequest

type SearchRequest struct {
	Query       string      `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
	Limit       int64       `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
	SortBy      SORT_BY     `protobuf:"varint,3,opt,name=sort_by,json=sortBy,proto3,enum=lure.SORT_BY" json:"sort_by,omitempty"`
	FilterType  FILTER_TYPE `protobuf:"varint,4,opt,name=filter_type,json=filterType,proto3,enum=lure.FILTER_TYPE" json:"filter_type,omitempty"`
	FilterValue *string     `protobuf:"bytes,5,opt,name=filter_value,json=filterValue,proto3,oneof" json:"filter_value,omitempty"`
	// contains filtered or unexported fields
}

SearchRequest is a request to search for packages

func (*SearchRequest) Descriptor deprecated

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

Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead.

func (*SearchRequest) GetFilterType

func (x *SearchRequest) GetFilterType() FILTER_TYPE

func (*SearchRequest) GetFilterValue

func (x *SearchRequest) GetFilterValue() string

func (*SearchRequest) GetLimit

func (x *SearchRequest) GetLimit() int64

func (*SearchRequest) GetQuery

func (x *SearchRequest) GetQuery() string

func (*SearchRequest) GetSortBy

func (x *SearchRequest) GetSortBy() SORT_BY

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 {
	Packages []*Package `protobuf:"bytes,1,rep,name=packages,proto3" json:"packages,omitempty"`
	// contains filtered or unexported fields
}

SearchResponse contains returned packages

func (*SearchResponse) Descriptor deprecated

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

Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead.

func (*SearchResponse) GetPackages

func (x *SearchResponse) GetPackages() []*Package

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 StringList

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

StringList contains a list of strings

func (*StringList) Descriptor deprecated

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

Deprecated: Use StringList.ProtoReflect.Descriptor instead.

func (*StringList) GetEntries

func (x *StringList) GetEntries() []string

func (*StringList) ProtoMessage

func (*StringList) ProtoMessage()

func (*StringList) ProtoReflect

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

func (*StringList) Reset

func (x *StringList) Reset()

func (*StringList) String

func (x *StringList) 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 NewAPIServer

func NewAPIServer(svc API, opts ...interface{}) TwirpServer

NewAPIServer 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