server

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package server provides HTTP server functionality for sql-http-proxy.

The mutation handler is one unit with the base handler in handler.go: it assembles a baseHandler field by field. See the namespace note there.

The query handler is one unit with the base handler in handler.go: it assembles a baseHandler field by field. See the namespace note there.

server.go is the unit this package is named for: it assembles the router from the configuration, and the API is read as server.NewServeMux without a prefix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServeMux

func NewServeMux(db *sqlx.DB, cfg config.Config, configDir string) (http.Handler, error)

NewServeMux creates a new chi Router with all configured handlers. db can be nil if all endpoints use mock. configDir is the directory of the config file for resolving relative paths.

Types

type HandlerExecutor added in v0.1.2

type HandlerExecutor[R any] interface {
	Execute(ctx context.Context, params map[string]any, opts executor.Options) (*R, error)
}

HandlerExecutor is the handler-side interface for query/mutation executors.

type HandlerResultProcessor added in v0.1.2

type HandlerResultProcessor[R any] interface {
	// BuildResponse returns (status, output, responseHeader) from the result.
	BuildResponse(result *R) (status int, output any, headers http.Header)
}

HandlerResultProcessor handles result-specific response building.

type MutationHandler

type MutationHandler = baseHandler[executor.MutationResult]

MutationHandler handles HTTP requests for mutations.

func NewMutationHandler

func NewMutationHandler(db *sqlx.DB, mutation config.Mutation) (*MutationHandler, error)

NewMutationHandler creates a new MutationHandler. db can be nil if mock is configured.

type QueryHandler

type QueryHandler = baseHandler[executor.ExecuteResult]

QueryHandler handles HTTP requests for queries.

func NewQueryHandler

func NewQueryHandler(db *sqlx.DB, query config.Query) (*QueryHandler, error)

NewQueryHandler creates a new QueryHandler. db can be nil if mock is configured.

Directories

Path Synopsis
Package body provides HTTP request body parsing with Content-Type handling.
Package body provides HTTP request body parsing with Content-Type handling.

Jump to

Keyboard shortcuts

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