proxy

package
v0.0.0-...-d9d2994 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

Types

type Handler

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

func NewHandler

func NewHandler(cfg *config.Config) (*Handler, error)

func (*Handler) ChatCompletions

func (h *Handler) ChatCompletions(w http.ResponseWriter, r *http.Request)

func (*Handler) Health

func (h *Handler) Health(w http.ResponseWriter, _ *http.Request)

func (*Handler) ProxyPassthrough

func (h *Handler) ProxyPassthrough(w http.ResponseWriter, r *http.Request)

type Server

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

func NewServer

func NewServer(cfg *config.Config) (*Server, error)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (s *Server) Start() error

type Upstream

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

func NewUpstream

func NewUpstream(cfg *config.Config) *Upstream

func (*Upstream) Forward

func (u *Upstream) Forward(reqBody []byte, authHeader string) (*UpstreamResult, error)

Forward sends a non-streaming request to the upstream provider.

func (*Upstream) ForwardRaw

func (u *Upstream) ForwardRaw(r *http.Request) (*http.Response, error)

ForwardRaw proxies any request directly to the upstream without parsing.

func (*Upstream) ForwardStream

func (u *Upstream) ForwardStream(reqBody []byte, authHeader string, w http.ResponseWriter) (*UpstreamResult, error)

ForwardStream sends a streaming request and writes SSE chunks directly to the client. It collects the full response content and usage for logging.

type UpstreamResult

type UpstreamResult struct {
	StatusCode int
	Header     http.Header
	Body       []byte
	Usage      *models.Usage
	Response   *models.ChatCompletionResponse
}

Jump to

Keyboard shortcuts

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