web

package
v0.0.0-...-f546f87 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 35

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(serviceName string, serviceArea byte, vnet uint32) ifs.IWebService

New creates a new WebService with the specified name, area, and VNet port. Automatically loads the registry plugin if available.

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

func (this *WebService) AddEndpoint(body proto.Message, action ifs.Action, resp proto.Message)

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.

Jump to

Keyboard shortcuts

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