api

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEndpointUsage = errRange.New(
		"Invalid API Usage",
		"APIs can not be referenced without being called, unless they are used as a cron job endpoint, or a PubSub subscription handler.",

		errors.WithDetails(baseHint),
	)

	ErrAPICalledOutsideService = errRange.New(
		"Invalid API call",
		"APIs can only be called from within a service, the current call site is outside any services within the application.",

		errors.WithDetails(baseHint),
	)

	ErrRawEndpointsCannotBeCalled = errRange.New(
		"Invalid API call",
		"Raw APIs cannot be called from within an Encore application.",
	)
)

Functions

func ResolveEndpointUsage

func ResolveEndpointUsage(data usage.ResolveData, ep *Endpoint) usage.Usage

Types

type AccessType

type AccessType string
const (
	Public  AccessType = "public"
	Private AccessType = "private"
	// Auth is like public but requires authentication.
	Auth AccessType = "auth"
)

type CallUsage

type CallUsage struct {
	usage.Base

	// Endpoint is the endpoint being called.
	Endpoint *Endpoint

	// Call is the function call expression.
	Call *ast.CallExpr
}

type Endpoint

type Endpoint struct {
	Name             string
	Doc              string
	File             *pkginfo.File
	Decl             *schema.FuncDecl
	Access           AccessType
	AccessField      option.Option[directive.Field]
	Raw              bool
	Path             *resourcepaths.Path
	HTTPMethods      []string
	HTTPMethodsField option.Option[directive.Field]
	Request          schema.Type // request data; nil for Raw Endpoints
	Response         schema.Type // response data; nil for Raw Endpoints
	Tags             selector.Set
	Recv             option.Option[*schema.Receiver] // None if not a method

	// Sensitive indicates whether the endpoint has been tagged as sensitive,
	// meaning all request/response information will be redacted in traces.
	Sensitive bool
	// contains filtered or unexported fields
}

func Parse

func Parse(d ParseData) *Endpoint

Parse parses an API endpoint. It may return nil on errors.

func (*Endpoint) End

func (ep *Endpoint) End() token.Pos

func (*Endpoint) GoString

func (ep *Endpoint) GoString() string

func (*Endpoint) Kind

func (ep *Endpoint) Kind() resource.Kind

func (*Endpoint) Package

func (ep *Endpoint) Package() *pkginfo.Package

func (*Endpoint) Pos

func (ep *Endpoint) Pos() token.Pos

func (*Endpoint) RequestEncoding

func (ep *Endpoint) RequestEncoding() []*apienc.RequestEncoding

func (*Endpoint) ResponseEncoding

func (ep *Endpoint) ResponseEncoding() *apienc.ResponseEncoding

func (*Endpoint) SortKey added in v1.16.3

func (ep *Endpoint) SortKey() string

type ParseData

type ParseData struct {
	Errs   *perr.List
	Schema *schema.Parser

	File *pkginfo.File
	Func *ast.FuncDecl
	Dir  *directive.Directive
	Doc  string
}

type ReferenceUsage

type ReferenceUsage struct {
	usage.Base

	// Endpoint is the endpoint being referenced.
	Endpoint *Endpoint

	// Ref is the reference expression.
	Ref ast.Expr
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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