server

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartUI added in v0.5.0

func StartUI(uiAddr, apiAddr string)

StartUI serves the web UI on uiAddr, pointing to the mock API server at apiAddr. It is non-blocking — call in a goroutine. A listen error (other than ErrServerClosed) is logged but does not terminate the process.

Types

type DataStore added in v0.5.0

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

DataStore is a named-collection in-memory CRUD store. Each collection holds objects identified by a string "id" field.

func (*DataStore) Clear added in v0.5.0

func (d *DataStore) Clear(name string)

Clear removes all items from the named collection.

func (*DataStore) ClearAll added in v0.5.0

func (d *DataStore) ClearAll()

ClearAll removes all collections.

func (*DataStore) Delete added in v0.5.0

func (d *DataStore) Delete(name, id string) bool

Delete removes the item with the given id. Returns true if found and removed.

func (*DataStore) Get added in v0.5.0

func (d *DataStore) Get(name, id string) (map[string]any, bool)

Get returns the item with the given id from the named collection.

func (*DataStore) List added in v0.5.0

func (d *DataStore) List(name string) []map[string]any

List returns a shallow copy of all items in the named collection.

func (*DataStore) Names added in v0.5.0

func (d *DataStore) Names() []string

Names returns the names of all collections that have been written to.

func (*DataStore) Patch added in v0.5.0

func (d *DataStore) Patch(name, id string, partial map[string]any) (map[string]any, bool)

Patch merges partial fields into the item with the given id. The "id" field is protected and cannot be overwritten. Returns the updated item and true, or nil and false if not found.

func (*DataStore) Push added in v0.5.0

func (d *DataStore) Push(name string, item map[string]any) map[string]any

Push appends item to the named collection after assigning a UUID "id". Returns the stored item (with id set).

func (*DataStore) Put added in v0.5.0

func (d *DataStore) Put(name, id string, item map[string]any) bool

Put replaces the item with the given id (upsert — inserts if not found). Returns true if an existing item was replaced, false if inserted.

func (*DataStore) SetCollection added in v0.5.0

func (d *DataStore) SetCollection(name string, items []map[string]any)

SetCollection replaces the entire named collection.

type DynamicRoute added in v0.4.0

type DynamicRoute struct {
	ID    string       `json:"id"`
	Route config.Route `json:"route"`
}

DynamicRoute is a route added at runtime via the introspection API.

type DynamicRouteStore added in v0.4.0

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

func (*DynamicRouteStore) Add added in v0.4.0

func (d *DynamicRouteStore) Add(route config.Route) string

func (*DynamicRouteStore) All added in v0.4.0

func (d *DynamicRouteStore) All() []DynamicRoute

func (*DynamicRouteStore) Clear added in v0.4.0

func (d *DynamicRouteStore) Clear()

func (*DynamicRouteStore) Remove added in v0.4.0

func (d *DynamicRouteStore) Remove(id string) bool

type RequestEntry added in v0.4.0

type RequestEntry struct {
	Time    time.Time         `json:"time"`
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Query   map[string]string `json:"query,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    string            `json:"body,omitempty"`
}

type RequestHistory added in v0.4.0

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

type Server added in v0.2.0

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

func New

func New(cfg *config.Config, verbose bool) *Server

func (*Server) Reload added in v0.2.0

func (s *Server) Reload(cfg *config.Config)

func (*Server) ServeHTTP added in v0.2.0

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

type StateStore added in v0.4.0

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

func (*StateStore) Get added in v0.4.0

func (s *StateStore) Get() string

func (*StateStore) Set added in v0.4.0

func (s *StateStore) Set(v string)

type VarStore added in v0.4.0

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

func (*VarStore) All added in v0.4.0

func (v *VarStore) All() map[string]string

func (*VarStore) Clear added in v0.4.0

func (v *VarStore) Clear()

func (*VarStore) Delete added in v0.4.0

func (v *VarStore) Delete(key string)

func (*VarStore) Get added in v0.4.0

func (v *VarStore) Get(key string) string

func (*VarStore) Set added in v0.4.0

func (v *VarStore) Set(key, val string)

Jump to

Keyboard shortcuts

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