Documentation
¶
Index ¶
- func Adapt[S any](fn func(grpc.ServiceRegistrar, S)) func(grpc.ServiceRegistrar, any)
- func BufferGrpcStream[M DataChunk](ctx context.Context, stream RecvStream[M], acceptable map[string]struct{}, ...) ([]byte, string, error)
- func RetryWithExponentialBackoff(ctx context.Context, maxRetries int, baseDelay time.Duration, fn func() error) error
- type BootServer
- type Builder
- func (b *Builder) AddMCPConfigurator(factory any) *Builder
- func (b *Builder) AddRestController(factory any) *Builder
- func (b *Builder) ApplySettings(opts []grpc.ServerOption) *Builder
- func (b *Builder) Build() (*BootServer, error)
- func (b *Builder) CORS(c *cors.Cors) *Builder
- func (b *Builder) ConfigureMCP(fn func(*mcp.Server)) *Builder
- func (b *Builder) EnableSSL(p SSLProvider) *Builder
- func (b *Builder) GRPCPort(p string) *Builder
- func (b *Builder) HTTPPort(p string) *Builder
- func (b *Builder) MCPHTTPOptions(opts *mcp.StreamableHTTPOptions) *Builder
- func (b *Builder) MCPPath(path string) *Builder
- func (b *Builder) Provide(value any) *Builder
- func (b *Builder) ProvideAs(value any, ifacePtr any) *Builder
- func (b *Builder) ProvideFunc(fn any) *Builder
- func (b *Builder) RegisterService(register func(grpc.ServiceRegistrar, any), factory any) *Builder
- func (b *Builder) RegisterTemporalActivity(factory any) *Builder
- func (b *Builder) RegisterTemporalWorkflow(w interface{}) *Builder
- func (b *Builder) StaticDir(dir string) *Builder
- func (b *Builder) Stream(i ...grpc.StreamServerInterceptor) *Builder
- func (b *Builder) Unary(i ...grpc.UnaryServerInterceptor) *Builder
- func (b *Builder) WithMCP(impl *mcp.Implementation, opts *mcp.ServerOptions) *Builder
- func (b *Builder) WithTemporal(taskQueue string, opts *client.Options) *Builder
- type DataChunk
- type MCPConfigurator
- type RecvStream
- type RestController
- type Route
- type SSLManager
- type SSLProvider
- type SslCloudCache
- type WebProxy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Adapt ¶ added in v1.0.2
func Adapt[S any](fn func(grpc.ServiceRegistrar, S)) func(grpc.ServiceRegistrar, any)
func BufferGrpcStream ¶ added in v1.0.15
func BufferGrpcStream[M DataChunk]( ctx context.Context, stream RecvStream[M], acceptable map[string]struct{}, maxSize int, ) ([]byte, string, error)
* Used to buffer a client-side gRPC stream. * Example usage: * rpc UploadProfileImage(stream UploadImageRequest) returns (UploadImageResponse) {} * * message UploadImageRequest { bytes chunkData = 1; } * * // server-side handler * func (s *Server) UploadProfileImage(stream grpc.ClientStreamingServer[pb.UploadImageRequest, pb.UploadImageResponse]) error { * ctx := stream.Context() * acceptable := map[string]struct{}{ * "image/jpeg": {}, * "image/png": {}, * } * * data, mime, err := BufferGrpcStream(ctx, stream, acceptable, 10*1024*1024) // 10 MB limit * }
Types ¶
type BootServer ¶ added in v1.0.0
type BootServer struct {
// contains filtered or unexported fields
}
type Builder ¶ added in v1.0.0
type Builder struct {
// contains filtered or unexported fields
}
─── public fluent builder ───────────────────────────────────
func (*Builder) AddMCPConfigurator ¶ added in v1.0.43
AddMCPConfigurator registers a factory function whose return type implements MCPConfigurator. Dependencies are injected the same way as for gRPC services and REST controllers. Example:
builder.AddMCPConfigurator(func(repo *UserRepo) *MyMCPTools {
return &MyMCPTools{repo: repo}
})
func (*Builder) AddRestController ¶ added in v1.0.38
AddRestController registers a REST controller factory for dependency injection. The factory is a function that takes dependencies as arguments and returns a type implementing RestController interface.
Example:
builder.AddRestController(func(userRepo UserRepository) *UserController {
return &UserController{repo: userRepo}
})
func (*Builder) ApplySettings ¶ added in v1.0.26
func (b *Builder) ApplySettings(opts []grpc.ServerOption) *Builder
Apply server settings
func (*Builder) Build ¶ added in v1.0.0
func (b *Builder) Build() (*BootServer, error)
func (*Builder) ConfigureMCP ¶ added in v1.0.43
ConfigureMCP registers a function that is called with the MCP server during Build. Use this to add tools, resources, and prompts directly:
builder.ConfigureMCP(func(s *mcp.Server) {
mcp.AddTool(s, &mcp.Tool{Name: "greet"}, SayHi)
})
func (*Builder) EnableSSL ¶ added in v1.0.0
func (b *Builder) EnableSSL(p SSLProvider) *Builder
func (*Builder) MCPHTTPOptions ¶ added in v1.0.43
func (b *Builder) MCPHTTPOptions(opts *mcp.StreamableHTTPOptions) *Builder
MCPHTTPOptions sets the StreamableHTTPOptions for the MCP handler. If nil, sensible defaults are used.
func (*Builder) MCPPath ¶ added in v1.0.43
MCPPath sets the HTTP path where the MCP server is mounted. Default is "/mcp".
func (*Builder) ProvideFunc ¶ added in v1.0.0
func (*Builder) RegisterService ¶ added in v1.0.10
func (*Builder) RegisterTemporalActivity ¶ added in v1.0.10
func (*Builder) RegisterTemporalWorkflow ¶ added in v1.0.10
func (*Builder) StaticDir ¶ added in v1.0.36
StaticDir sets the directory to serve static files from (e.g., "./static"). Static files will be served on the same HTTP port at /static/* path.
func (*Builder) Stream ¶ added in v1.0.0
func (b *Builder) Stream(i ...grpc.StreamServerInterceptor) *Builder
func (*Builder) Unary ¶ added in v1.0.0
func (b *Builder) Unary(i ...grpc.UnaryServerInterceptor) *Builder
func (*Builder) WithMCP ¶ added in v1.0.43
func (b *Builder) WithMCP(impl *mcp.Implementation, opts *mcp.ServerOptions) *Builder
WithMCP enables an MCP (Model Context Protocol) server on the HTTP port. The server is served via the Streamable HTTP transport at the configured path (default "/mcp"). Use AddMCPConfigurator or ConfigureMCP to add tools, resources and prompts to the server.
type MCPConfigurator ¶ added in v1.0.43
MCPConfigurator is implemented by types that configure an MCP server with tools, resources, prompts, etc. It is the MCP equivalent of RestController – register a factory via Builder.AddMCPConfigurator and go-api-boot will inject dependencies and call ConfigureMCP during Build.
type RecvStream ¶ added in v1.0.15
type RestController ¶ added in v1.0.38
type RestController interface {
// Routes returns the HTTP routes handled by this controller.
Routes() []Route
}
RestController is an interface for HTTP REST controllers. Controllers implementing this interface can be registered with the Builder and will have their dependencies automatically injected.
type Route ¶ added in v1.0.38
type Route struct {
// Pattern is the URL pattern for the route (e.g., "/api/users", "/api/users/{id}").
Pattern string
// Method is the HTTP method for the route (GET, POST, PUT, DELETE, etc.).
// If empty, the route will handle all HTTP methods.
Method string
// Handler is the HTTP handler function for the route.
Handler http.HandlerFunc
}
Route defines a single HTTP route with its pattern and handler.
type SSLManager ¶ added in v0.1.46
type SSLManager struct {
// contains filtered or unexported fields
}
func NewSSLManager ¶ added in v0.1.46
func NewSSLManager(domain string, cache autocert.Cache) *SSLManager
NewSSLManager uses any autocert.Cache (dir, cloud, memory…)
type SSLProvider ¶ added in v1.0.0
type SSLProvider interface {
// Configure mutates srv.TLSConfig so that http.Server can serve TLS.
Configure(srv *http.Server) error
// Run launches any background logic the provider needs
// (ACME challenge listener, certificate refresh, etc.).
// It must return when ctx is cancelled.
Run(ctx context.Context) error
}
func CloudCacheProvider ¶ added in v1.0.0
func CloudCacheProvider(cfg *config.BootConfig, cloud cloud.Cloud) SSLProvider
Cloud provider (wraps SSLManager with SslCloudCache)
type SslCloudCache ¶ added in v0.1.48
type SslCloudCache struct {
// contains filtered or unexported fields
}
func NewSslCloudCache ¶ added in v0.1.48
func NewSslCloudCache(cfg *config.BootConfig, cloud cloud.Cloud) *SslCloudCache
ctor
func (*SslCloudCache) Delete ¶ added in v0.1.48
func (cc *SslCloudCache) Delete(ctx context.Context, name string) error
type WebProxy ¶ added in v0.1.34
type WebProxy struct {
// contains filtered or unexported fields
}