Documentation
¶
Index ¶
- Constants
- Variables
- func GetMiddlewareCreated(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
- func GetMiddlewareNoContent(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
- func GetMiddlewareOk(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
- func NewMiddleware(logger *glog.Logger, requestReader RequestReader, ...) (func(gin.HandlerFunc) gin.HandlerFunc, error)
- func RequestReaderDefault(ctx *gin.Context) (map[string]interface{}, error)
- type Provider
- type RequestReader
- type RequestReaderDecorator
- type ResponseReader
- type ResponseReaderDecorator
Constants ¶
const ( // ContainerID defines the id to be used as the container // registration id of a logging middleware instance factory function. ContainerID = gapp.ContainerID + ".rest.log" // ContainerOkID defines the id to be used as the // container registration id of a standard log middleware generator // for a 200(OK) status code. ContainerOkID = ContainerID + ".ok" // ContainerCreatedID defines the id to be used as // the container registration id of a standard log middleware generator // for a 201(Created) status code. ContainerCreatedID = ContainerID + ".created" // ContainerNoContentID defines the id to be used as // the container registration id of a standard log middleware generator // for a 204(NoContent) status code. ContainerNoContentID = ContainerID + ".no_content" )
Variables ¶
var ( // ErrNilPointer defines a nil pointer argument error ErrNilPointer = gapp.ErrNilPointer // ErrConversion defines a type conversion error ErrConversion = gapp.ErrConversion )
var ( // RequestChannel defines the channel id to be used when // the log middleware sends the request logging signal to the logger // instance. RequestChannel = genv.String("GAPP_REST_LOG_REQUEST_CHANNEL", "transport") // RequestLevel defines the logging level to be used when // the log middleware sends the request logging signal to the logger // instance. RequestLevel = envToLogLevel("GAPP_REST_LOG_REQUEST_LEVEL", glog.DEBUG) // RequestMessage defines the request event logging message to // be used when the log middleware sends the logging signal to the logger // instance. RequestMessage = genv.String("GAPP_REST_LOG_REQUEST_MESSAGE", "Request") // ResponseChannel defines the channel id to be used when the // log middleware sends the response logging signal to the logger instance. ResponseChannel = genv.String("GAPP_REST_LOG_RESPONSE_CHANNEL", "transport") // ResponseLevel defines the logging level to be used when the // log middleware sends the response logging signal to the logger instance. ResponseLevel = envToLogLevel("GAPP_REST_LOG_RESPONSE_LEVEL", glog.INFO) // ResponseMessage defines the response event logging message // to be used when the log middleware sends the logging signal to the // logger instance. ResponseMessage = genv.String("GAPP_REST_LOG_RESPONSE_MESSAGE", "Response") // DecorateJSON flag that defines the decoration of the log entries // for JSON body content. DecorateJSON = genv.Bool("GAPP_REST_LOG_DECORATE_JSON", true) // DecorateXML flag that defines the decoration of the log entries // for XML body content. DecorateXML = genv.Bool("GAPP_REST_LOG_DECORATE_XML", false) )
Functions ¶
func GetMiddlewareCreated ¶
func GetMiddlewareCreated(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
GetMiddlewareCreated will try to retrieve the registered logging middleware for created responses instance from the application service container.
func GetMiddlewareNoContent ¶
func GetMiddlewareNoContent(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
GetMiddlewareNoContent will try to retrieve the registered logging middleware for no-content responses instance from the application service container.
func GetMiddlewareOk ¶
func GetMiddlewareOk(c gapp.ServiceContainer) (func(next gin.HandlerFunc) gin.HandlerFunc, error)
GetMiddlewareOk will try to retrieve the registered logging middleware for ok responses instance from the application service container.
func NewMiddleware ¶
func NewMiddleware( logger *glog.Logger, requestReader RequestReader, responseReader ResponseReader, ) (func(gin.HandlerFunc) gin.HandlerFunc, error)
NewMiddleware will instantiate a new middleware that will emit logging signals on a request event and on a response event.
Types ¶
type Provider ¶
type Provider struct{}
Provider defines the gapp-rest-log module service provider to be used on the application initialization to register the logging middleware service.
type RequestReader ¶
RequestReader defines the function used by the middleware that compose the logging request context object.
func NewRequestReaderDecoratorJSON ¶
func NewRequestReaderDecoratorJSON(reader RequestReader, model interface{}) (RequestReader, error)
NewRequestReaderDecoratorJSON will instantiate a new request event context reader JSON decorator used to parse the request body as a JSON and add the parsed content into the logging data.
func NewRequestReaderDecoratorXML ¶
func NewRequestReaderDecoratorXML(reader RequestReader, model interface{}) (RequestReader, error)
NewRequestReaderDecoratorXML will instantiate a new request event context reader XML decorator used to parse the request body as an XML and add the parsed content into the logging data.
type RequestReaderDecorator ¶
type RequestReaderDecorator func(reader RequestReader, model interface{}) (RequestReader, error)
RequestReaderDecorator defines a function used to decorate a request reader output.
type ResponseReader ¶
ResponseReader defines the interface methods of a response context reader used to compose the data to be sent to the logger on a response event.
func NewResponseReaderDecoratorJSON ¶
func NewResponseReaderDecoratorJSON(reader ResponseReader, model interface{}) (ResponseReader, error)
NewResponseReaderDecoratorJSON will instantiate a new response event context reader JSON decorator used to parse the response body as a JSON and add the parsed content into the logging data.
func NewResponseReaderDecoratorXML ¶
func NewResponseReaderDecoratorXML(reader ResponseReader, model interface{}) (ResponseReader, error)
NewResponseReaderDecoratorXML will instantiate a new response event context reader XML decorator used to parse the response body as an XML and add the parsed content into the logging data.
func NewResponseReaderDefault ¶
func NewResponseReaderDefault(statusCode int) ResponseReader
NewResponseReaderDefault generates a new default response reader with the defined expected status code.
type ResponseReaderDecorator ¶
type ResponseReaderDecorator func(reader ResponseReader, model interface{}) (ResponseReader, error)
ResponseReaderDecorator defines a function used to decorate a response reader output.
Source Files
¶
- container.go
- errors.go
- globals.go
- middleware.go
- provider.go
- request_reader.go
- request_reader_decorator.go
- request_reader_decorator_json.go
- request_reader_decorator_xml.go
- request_reader_default.go
- response_reader.go
- response_reader_decorator.go
- response_reader_decorator_json.go
- response_reader_decorator_xml.go
- response_reader_default.go
- response_writer.go