Documentation ¶
Overview ¶
Package rest provides the implementation of a REST API server using the Huma framework. This package includes server initialization, configuration, middleware setup, and server start/stop functionalities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error424FailedDependency ¶
Error424FailedDependency returns a 424.
Types ¶
type Namespace ¶
type Namespace interface { // GetName returns the name of the service. GetName() ServiceName // RegisterHandlers registers the HTTP handlers for the namespace. RegisterHandlers() error }
Namespace defines an interface for service namespaces.
type Response ¶
type Response[T any] struct { Body T }
Response is a generic struct for wrapping API responses.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a REST API server.
func NewServer ¶
func NewServer(ctx context.Context, dbAdapter db.Adapter, redis *cache.Redis, opts options.Rest) (*Server, error)
NewServer creates a new REST API server instance with the provided context, database adapter, Redis cache, and server options.
Parameters: - ctx: The context to control server lifecycle. - dbAdapter: Database adapter for database interactions. - redis: Redis cache instance for caching. - opts: Server options including OpenAPI configuration and server address.
Returns: - A pointer to the newly created Server instance. - An error if any issue occurs during server creation.
func (*Server) GetAPI ¶
func (s *Server) GetAPI() huma.API
GetAPI returns the Huma API instance associated with the server.
Returns: - The Huma API instance.
func (*Server) GetOptions ¶
func (*Server) GetRouter ¶
func (s *Server) GetRouter() *chi.Mux
GetRouter returns the HTTP router used by the server.
Returns: - The HTTP router.
type ServiceName ¶
type ServiceName string
ServiceName represents the name of a service as a string.
func (ServiceName) String ¶
func (s ServiceName) String() string
String converts the ServiceName to a string.