Documentation
¶
Overview ¶
Package web provides RESTful web service definition and request handling utilities. It enables defining service endpoints with protocol buffer request/response types and supports multiple body types per action for flexible API design.
Key features:
- Define HTTP endpoints with protobuf body/response types
- Automatic JSON-to-protobuf unmarshaling for request bodies
- Support for multiple request body types per endpoint
- VNet (Virtual Network) integration for service-to-service communication
- Plugin registry loading for service extensions
Index ¶
- func New(serviceName string, serviceArea byte, vnet uint32) ifs.IWebService
- type WebService
- func (this *WebService) AddEndpoint(body proto.Message, action ifs.Action, resp proto.Message)
- func (this *WebService) DeSerialize(ws *l8web.L8WebService, r ifs.IRegistry) error
- func (this *WebService) Plugin() string
- func (this *WebService) Protos(bodyData string, action ifs.Action) (proto.Message, proto.Message, error)
- func (this *WebService) Serialize() *l8web.L8WebService
- func (this *WebService) ServiceArea() byte
- func (this *WebService) ServiceName() string
- func (this *WebService) Vnet() uint32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type WebService ¶
type WebService struct {
// contains filtered or unexported fields
}
WebService defines a RESTful service with typed endpoints using protocol buffers. Each endpoint maps an action to request/response protobuf types.
func (*WebService) AddEndpoint ¶
AddEndpoint registers a new endpoint mapping an action to body and response types. Multiple body types can be registered for the same action.
func (*WebService) DeSerialize ¶
func (this *WebService) DeSerialize(ws *l8web.L8WebService, r ifs.IRegistry) error
DeSerialize reconstructs the WebService from a serialized L8WebService using the registry.
func (*WebService) Plugin ¶
func (this *WebService) Plugin() string
Plugin returns the base64-encoded plugin binary if available.
func (*WebService) Protos ¶
func (this *WebService) Protos(bodyData string, action ifs.Action) (proto.Message, proto.Message, error)
Protos parses the JSON request body and returns the appropriate request/response proto types. Tries the primary body type first, then falls back to alternative types if parsing fails.
func (*WebService) Serialize ¶
func (this *WebService) Serialize() *l8web.L8WebService
Serialize returns the underlying L8WebService protobuf for transmission.
func (*WebService) ServiceArea ¶
func (this *WebService) ServiceArea() byte
ServiceArea returns the service area identifier.
func (*WebService) ServiceName ¶
func (this *WebService) ServiceName() string
ServiceName returns the name of this web service.
func (*WebService) Vnet ¶
func (this *WebService) Vnet() uint32
Vnet returns the VNet port for service-to-service communication.