server

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package server provides a pluggable SDK-compatible HTTP server.

The core Server is protocol-agnostic: it dispatches incoming requests to registered Handlers via a Matches predicate. Each Handler is a self-contained package (e.g. server/aws/s3, server/aws/dynamodb) that speaks its own wire format. Adding a new service — AWS EC2, Azure Blob, GCP GCS — is one new package and one Register call; the core server never changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Matches(r *http.Request) bool
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

Handler is a self-contained protocol handler registered with a Server. Matches inspects the request and returns true if this handler should serve it; ServeHTTP writes the response. Handlers are evaluated in registration order, first match wins.

type Server

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

Server routes incoming HTTP requests to registered Handlers. Server itself implements http.Handler, so httptest.NewServer(srv) works.

func New

func New(handlers ...Handler) *Server

New creates a Server preloaded with the given handlers. Additional handlers can be added later via Register.

func (*Server) Close

func (s *Server) Close() error

Close shuts down the listener started by Start.

func (*Server) Register

func (s *Server) Register(h Handler)

Register appends a handler. Handlers registered earlier take precedence, so register more specific handlers before catch-all ones.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches to the first handler whose Matches returns true, or responds 501 Not Implemented if no handler matches.

func (*Server) Start

func (s *Server) Start(addr string) error

Start listens on addr and serves requests. Blocks until Close is called.

Directories

Path Synopsis
aws
Package aws assembles CloudEmu's AWS-compatible HTTP server.
Package aws assembles CloudEmu's AWS-compatible HTTP server.
dynamodb
Package dynamodb implements the DynamoDB JSON-RPC protocol as a server.Handler.
Package dynamodb implements the DynamoDB JSON-RPC protocol as a server.Handler.
s3
Package s3 implements the S3 REST+XML protocol as a server.Handler.
Package s3 implements the S3 REST+XML protocol as a server.Handler.
Package wire provides shared HTTP wire-format helpers for service handlers: XML and JSON encoding, JSON decoding, and HTTP-date formatting.
Package wire provides shared HTTP wire-format helpers for service handlers: XML and JSON encoding, JSON decoding, and HTTP-date formatting.

Jump to

Keyboard shortcuts

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