Documentation
¶
Index ¶
- func ConvertEventToBytes(event interface{}, contentType string) ([]byte, error)
- func GetStatusCodeFromMetadata(metadata map[string]string) int
- func UniversalFastHTTPHandler[T proto.Message, U proto.Message](handler func(ctx context.Context, in T) (U, error), ...) fasthttp.RequestHandler
- type API
- type APIOpts
- type BulkGetRequest
- type BulkGetResponse
- type BulkPublishResponse
- type BulkPublishResponseFailedEntry
- type Endpoint
- type ErrorResponse
- type NewServerOpts
- type OutputBindingRequest
- type QueryItem
- type QueryResponse
- type Server
- type ServerConfig
- type UniversalFastHTTPHandlerOpts
- type UniversalHTTPRawResponse
- type UnsubscribeConfigurationResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertEventToBytes ¶ added in v1.10.0
func GetStatusCodeFromMetadata ¶
GetStatusCodeFromMetadata extracts the http status code from the metadata if it exists.
func UniversalFastHTTPHandler ¶ added in v1.10.1
func UniversalFastHTTPHandler[T proto.Message, U proto.Message]( handler func(ctx context.Context, in T) (U, error), opts UniversalFastHTTPHandlerOpts[T, U], ) fasthttp.RequestHandler
UniversalFastHTTPHandler wraps a UniversalAPI method into a FastHTTP handler.
Types ¶
type API ¶
type API interface {
APIEndpoints() []Endpoint
PublicEndpoints() []Endpoint
MarkStatusAsReady()
MarkStatusAsOutboundReady()
SetAppChannel(appChannel channel.AppChannel)
SetHTTPEndpointsAppChannel(appChannel channel.HTTPEndpointAppChannel)
SetDirectMessaging(directMessaging messaging.DirectMessaging)
SetActorRuntime(actor actors.Actors)
}
API returns a list of HTTP endpoints for Dapr.
type APIOpts ¶ added in v1.10.0
type APIOpts struct {
AppID string
AppChannel channel.AppChannel
HTTPEndpointsAppChannel channel.HTTPEndpointAppChannel
DirectMessaging messaging.DirectMessaging
Resiliency resiliency.Provider
CompStore *compstore.ComponentStore
PubsubAdapter runtimePubsub.Adapter
Actor actors.Actors
SendToOutputBindingFn func(name string, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error)
TracingSpec config.TracingSpec
Shutdown func()
GetComponentsCapabilitiesFn func() map[string][]string
MaxRequestBodySize int64 // In bytes
IsStreamingEnabled bool
}
APIOpts contains the options for NewAPI.
type BulkGetRequest ¶ added in v0.10.0
type BulkGetRequest struct {
Metadata map[string]string `json:"metadata"`
Keys []string `json:"keys"`
Parallelism int `json:"parallelism"`
}
BulkGetRequest is the request object to get a list of values for multiple keys from a state store.
type BulkGetResponse ¶ added in v0.10.0
type BulkGetResponse struct {
Key string `json:"key"`
Data json.RawMessage `json:"data,omitempty"`
ETag *string `json:"etag,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Error string `json:"error,omitempty"`
}
BulkGetResponse is the response object for a state bulk get operation.
type BulkPublishResponse ¶ added in v1.10.0
type BulkPublishResponse struct {
FailedEntries []BulkPublishResponseFailedEntry `json:"failedEntries"`
ErrorCode string `json:"errorCode,omitempty"`
}
BulkPublishResponse is the response for bulk publishing events
type BulkPublishResponseFailedEntry ¶ added in v1.10.0
type BulkPublishResponseFailedEntry struct {
EntryId string `json:"entryId"` //nolint:stylecheck
Error string `json:"error,omitempty"`
}
BulkPublishResponseEntry is an object representing a single entry in bulk publish response
type Endpoint ¶
type Endpoint struct {
Methods []string
Route string
Version string
Alias string
KeepParamUnescape bool // keep the param in path unescaped
Handler fasthttp.RequestHandler
AlwaysAllowed bool // Endpoint is always allowed regardless of API access rules
IsHealthCheck bool // Mark endpoint as healthcheck - for API logging purposes
}
Endpoint is a collection of route information for an Dapr API.
If an Alias, e.g. "hello", is provided along with the Route, e.g. "invoke/app-id/method/hello" and the Version, "v1.0", then two endpoints will be installed instead of one. Besiding the canonical Dapr API URL "/v1.0/invoke/app-id/method/hello", one another URL "/hello" is provided for the Alias. When Alias URL is used, extra infos are required to pass through HTTP headers, for example, application's ID.
func (Endpoint) IsAllowed ¶ added in v1.11.0
func (endpoint Endpoint) IsAllowed(allowedAPIs []config.APIAccessRule, deniedAPIs []config.APIAccessRule) bool
IsAllowed returns true if the endpoint is allowed given the API allowlist/denylist.
type ErrorResponse ¶
ErrorResponse is an HTTP response message sent back to calling clients by the Dapr Runtime HTTP API.
func NewErrorResponse ¶
func NewErrorResponse(errorCode, message string) ErrorResponse
NewErrorResponse returns a new ErrorResponse.
type NewServerOpts ¶ added in v1.9.0
type NewServerOpts struct {
API API
Config ServerConfig
TracingSpec config.TracingSpec
MetricSpec config.MetricSpec
Pipeline httpMiddleware.Pipeline
APISpec config.APISpec
}
NewServerOpts are the options for NewServer.
type OutputBindingRequest ¶
type OutputBindingRequest struct {
Metadata map[string]string `json:"metadata"`
Data interface{} `json:"data"`
Operation string `json:"operation"`
}
OutputBindingRequest is the request object to invoke an output binding.
type QueryItem ¶ added in v1.5.0
type QueryItem struct {
Key string `json:"key"`
Data json.RawMessage `json:"data"`
ETag *string `json:"etag,omitempty"`
Error string `json:"error,omitempty"`
}
QueryItem is an object representing a single entry in query results.
type QueryResponse ¶ added in v1.5.0
type QueryResponse struct {
Results []QueryItem `json:"results"`
Token string `json:"token,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
QueryResponse is the response object for querying state.
type ServerConfig ¶
type ServerConfig struct {
AppID string
HostAddress string
Port int
APIListenAddresses []string
PublicPort *int
ProfilePort int
AllowedOrigins string
EnableProfiling bool
MaxRequestBodySize int
UnixDomainSocket string
ReadBufferSize int
EnableAPILogging bool
APILoggingObfuscateURLs bool
APILogHealthChecks bool
}
ServerConfig holds config values for an HTTP server.
type UniversalFastHTTPHandlerOpts ¶ added in v1.10.1
type UniversalFastHTTPHandlerOpts[T proto.Message, U proto.Message] struct { // This modifier allows modifying the input proto object before the handler is called. This property is optional. // The input proto object contantains all properties parsed from the request's body (for non-GET requests), and this modifier can alter it for example with properties from the URL (to make APIs RESTful). // The modifier should return the modified object. InModifier func(reqCtx *fasthttp.RequestCtx, in T) (T, error) // This modifier allows modifying the output proto object before the response is sent to the client. This property is optional. // This is primarily meant to ensure that existing APIs can be migrated to Universal ones while preserving the same response in case of small differences. // The response could be a proto object (which will be serialized with protojson) or any other object (serialized with the standard JSON package). If the response is nil, a 204 (no content) response is sent to the client, with no data in the body. // NOTE: Newly-implemented APIs should ensure that on the HTTP endpoint the response matches the protos to offer a consistent experience, and should NOT modify the output before it's sent to the client. OutModifier func(out U) (any, error) // Status code to return on successful responses. // Defaults to 200 (OK) if unset. SuccessStatusCode int // If true, skips parsing the body of the request in the input proto. SkipInputBody bool // When true, unpopulated fields in proto responses (i.e. fields whose value is the zero one) are included in the response too. // Defaults to false. ProtoResponseEmitUnpopulated bool }
Object containing options for the UniversalFastHTTPHandler method.
type UniversalHTTPRawResponse ¶ added in v1.11.0
type UniversalHTTPRawResponse struct {
// Body of the response.
Body []byte
// Optional value for the Content-Type header to send.
ContentType string
// Optional status code; if empty, uses the default SuccessStatusCode.
StatusCode int
}
Contains a pre-serialized response as well as its content type. An OutModifier can return this object if it needs to serialize the response itself.