httpactor

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTP uses the same body codec IDs and payload rules as AGP.
	ContentTypeJSON     = "application/json"
	ContentTypeProtobuf = "application/x-protobuf"
	// TimeoutHeader lets curl and other HTTP clients request a shorter deadline.
	TimeoutHeader = "X-ActorGo-Timeout-Ms"
	// Route is the fixed Gin route for all remotely registered Actor methods.
	Route = "/actor/:methodID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator func(*http.Request) (*cproto.Session, error)

Authenticator resolves the server-owned caller session before dispatching to an Actor. Returning nil keeps the request anonymous.

type Component

type Component struct {
	cfacade.Component
	// contains filtered or unexported fields
}

Component runs the Actor HTTP handler as a standalone net/http server.

func NewComponent

func NewComponent(name, address string, opts ...Option) *Component

NewComponent creates a standalone Actor HTTP endpoint.

func (*Component) Handler

func (c *Component) Handler() *Handler

Handler returns the initialized HTTP transport adapter.

func (*Component) Init

func (c *Component) Init()

Init builds the handler and HTTP server after the application is attached.

func (*Component) Name

func (c *Component) Name() string

Name returns the application-unique component name.

func (*Component) OnAfterInit

func (c *Component) OnAfterInit()

OnAfterInit starts listening after Actor routes are available.

func (*Component) OnStop

func (c *Component) OnStop()

OnStop performs a bounded graceful HTTP shutdown.

type Handler

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

Handler exposes every Methods().Register method through POST /actor/{methodID}.

func NewHandler

func NewHandler(app cfacade.IApplication, opts ...Option) *Handler

NewHandler creates the transport adapter over the application's method table.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP validates the fixed route, selects JSON/PB from Content-Type and delegates decoding and Actor routing to the shared method table.

type Option

type Option func(*Options)

Option mutates HTTP Actor options during construction.

func WithAuthenticator

func WithAuthenticator(authenticator Authenticator) Option

WithAuthenticator installs one authenticator for all Actor HTTP methods.

func WithMaxBodySize

func WithMaxBodySize(size int64) Option

WithMaxBodySize limits the encoded request body.

func WithMetadataHeaders

func WithMetadataHeaders(headers ...string) Option

WithMetadataHeaders selects HTTP headers copied into RequestContext.Metadata.

func WithTimeout

func WithTimeout(defaultTimeout, maxTimeout time.Duration) Option

WithTimeout sets the default request deadline and the client-requested cap.

type Options

type Options struct {
	MaxBodySize     int64
	DefaultTimeout  time.Duration
	MaxTimeout      time.Duration
	Authenticator   Authenticator
	MetadataHeaders []string
}

Options controls global HTTP Actor limits and authentication.

Jump to

Keyboard shortcuts

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