adapters

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package adapters provides infrastructure adapters for the notification feature.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

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

HTTPClient implements ports.Service by calling a remote notification service over HTTP. It demonstrates how a standalone process can consume a feature without importing its implementation.

func NewHTTPClient

func NewHTTPClient(baseURL string, client *http.Client) (*HTTPClient, error)

NewHTTPClient creates a remote notification client.

baseURL must be a non-empty string. If client is nil, http.DefaultClient is used.

func (*HTTPClient) Send

func (c *HTTPClient) Send(ctx context.Context, message string) error

Send implements ports.Service by forwarding the message to the remote service.

type HTTPServer

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

HTTPServer exposes the notification service over HTTP. It keeps HTTP concerns (encoding, status codes) separate from business logic.

func NewHTTPServer

func NewHTTPServer(svc ports.Service, logger *slog.Logger) *HTTPServer

NewHTTPServer creates an HTTP adapter for the notification service.

func (*HTTPServer) SendHandler

func (s *HTTPServer) SendHandler() http.HandlerFunc

SendHandler returns an http.HandlerFunc that forwards requests to the notification service.

type SendRequest

type SendRequest struct {
	Message string `json:"message"`
}

SendRequest is the JSON body accepted by the send endpoint.

type SendResponse

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

SendResponse is the JSON body returned by the send endpoint.

Jump to

Keyboard shortcuts

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