api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package api provides an HTTP API server for hawk, consumable by SDKs.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the current hawk API surface version, exposed in the GET /version endpoint. It is wired at startup by main.go from the canonical version (the VERSION file at the repo root, injected via ldflags). The "dev" default applies only to local builds without ldflags.

Functions

func SetVersion added in v0.2.0

func SetVersion(v string)

SetVersion lets main.go propagate the canonical hawk version into this package without creating an import cycle with cmd.

Types

type ChatRequest

type ChatRequest struct {
	Message string `json:"message"`
	Model   string `json:"model"`
}

ChatRequest is the request body for POST /chat.

type ChatResponse

type ChatResponse struct {
	Response string `json:"response"`
}

ChatResponse is the response body for POST /chat.

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

HealthResponse is the response body for GET /health.

type Server

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

Server is the HTTP API server for hawk.

func New

func New(addr string) *Server

New creates a new API server listening on the given address.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the underlying http.Handler for testing purposes.

func (*Server) Start

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

Start starts the HTTP server. It blocks until the context is cancelled or an error occurs.

func (*Server) Stop

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

Stop gracefully shuts down the HTTP server.

type VersionResponse

type VersionResponse struct {
	Version string `json:"version"`
}

VersionResponse is the response body for GET /version.

Jump to

Keyboard shortcuts

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