Documentation ¶
Overview ¶
Package bone is a Non-intrusive Go micro-service framework, to combine modules organically, base on go-kit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // NewServer is shortcut of go-kit's http.NewServer. // NewServer constructs a new server, which implements http.Handler and wraps // the provided endpoint. NewServer = http.NewServer // EncodeJSONResquest is shortcut of go-kit's http.EncodeJSONRequest. // EncodeJSONRequest is an EncodeRequestFunc that serializes the request as a // JSON object to the Request body. Many JSON-over-HTTP services can use it as // a sensible default. If the request implements Headerer, the provided headers // will be applied to the request. EncodeJSONRequest = http.EncodeJSONRequest // EncodeXMLRequest is shortcut of go-kit's http.EncodeXMLRequest. // EncodeXMLRequest is an EncodeRequestFunc that serializes the request as a // XML object to the Request body. If the request implements Headerer, // the provided headers will be applied to the request. EncodeXMLRequest = http.EncodeXMLRequest // EncodeJSONResponse is shortcut of go-kit's http.EncodeJSONResponse. // EncodeJSONResponse is a EncodeResponseFunc that serializes the response as a // JSON object to the ResponseWriter. Many JSON-over-HTTP services can use it as // a sensible default. If the response implements Headerer, the provided headers // will be applied to the response. If the response implements StatusCoder, the // provided StatusCode will be used instead of 200. EncodeJSONResponse = http.EncodeJSONResponse )
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application defines the struct of Bone Application.
func NewApplication ¶
func NewApplication(options *ApplicationOptions) *Application
NewApplication returns the instance of Bone Application.
func (*Application) Provide ¶ added in v0.0.5
func (app *Application) Provide(obj *inject.Object) error
Provide is a low-level API to provide *inject.Object to inject Bone Application. Do NOT use it except must to.
func (*Application) Use ¶
func (app *Application) Use(components ...Component)
Use injects the components to the Bone Application, combines other component into a interconnected system.
type ApplicationOptions ¶
type ApplicationOptions struct { // Basic part Debug bool // HTTP part HttpEnable bool HttpHost string HttpPort int // gRPC part GrpcEnable bool GrpcHost string GrpcPort int }
ApplicationOptions represents the options to create Bone Application instance.
func DefaultApplicationOptions ¶
func DefaultApplicationOptions() *ApplicationOptions
DefaultApplicationOptions returns the default options to create Bone Application instance. Enable HTTP Server and disable gRPC Server by default.
type Controller ¶
type Controller interface { // Register should be used to registering handlers. Register() error }
Controller is a special component, which should be used for the controller's definition.
type Endpoint ¶
type Endpoint interface { }
Endpoint is a special component, which should be used for the endpoint's definition.
type Handler ¶
Handler defines how to handle a http request, should have decoding part and proccessing part at the same time.
type Logger ¶
type Logger interface { Component // WithContext returns Logger, which has its own context, convenient for // tracking. WithContext(ctx context.Context) Logger // Debug logs to the DEBUG log. Debug(msg any, extra ...map[string]any) // Info logs to the INFO log. Info(msg any, extra ...map[string]any) // Warn logs to the WARN log. Warn(msg any, extra ...map[string]any) // Error logs to the Error log. Error(msg any, extra ...map[string]any) // Panic logs to the PANIC log. And application should panic, which is // recoverable, after calling this method. Panic(msg any, extra ...map[string]any) // Fatal logs to the FATAL log. And application should fatal, which is NOT // recoverable, after calling this method. Fatal(msg any, extra ...map[string]any) }
Logger defines the common log methods.
type Model ¶
type Model interface { }
Model is a special component, which should be used for the model's definition.
type Module ¶
type Module interface { Component }
Module is a special component, which should be used for the module's definition.
type Repo ¶
type Repo interface { }
Repo is a special component, which should be used for the repository's definition.