mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-10 09:32:13 +01:00
feat: add metrics system, move webhook feature to dedicated module (#372)
This commit is contained in:
@@ -227,9 +227,9 @@ func (ctx Context) Log() *zap.Logger {
|
||||
return ctx.logger
|
||||
}
|
||||
|
||||
// buildOutputFile builds the output file according to the output paths
|
||||
// BuildOutputFile builds the output file according to the output paths
|
||||
// registered in the context. If many output paths, an archive is created.
|
||||
func (ctx Context) buildOutputFile() (string, error) {
|
||||
func (ctx Context) BuildOutputFile() (string, error) {
|
||||
if ctx.cancelled {
|
||||
return "", ErrContextAlreadyClosed
|
||||
}
|
||||
@@ -265,6 +265,18 @@ func (ctx Context) buildOutputFile() (string, error) {
|
||||
return archivePath, nil
|
||||
}
|
||||
|
||||
// OutputFilename returns the filename based on the given output path or the
|
||||
// "Gotenberg-Output-Filename" header's value.
|
||||
func (ctx Context) OutputFilename(outputPath string) string {
|
||||
filename := ctx.echoCtx.Request().Header.Get("Gotenberg-Output-Filename")
|
||||
|
||||
if filename == "" {
|
||||
return filepath.Base(outputPath)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%s", filename, filepath.Ext(outputPath))
|
||||
}
|
||||
|
||||
// MockContext is a helper for tests.
|
||||
//
|
||||
// ctx := &api.MockContext{Context: &api.Context{}}
|
||||
@@ -316,3 +328,19 @@ func (ctx *MockContext) SetCancelled(cancelled bool) {
|
||||
func (ctx MockContext) OutputPaths() []string {
|
||||
return ctx.outputPaths
|
||||
}
|
||||
|
||||
// SetLogger sets the logger.
|
||||
//
|
||||
// ctx := &api.MockContext{Context: &api.Context{}}
|
||||
// ctx.SetLogger(zap.NewNop())
|
||||
func (ctx *MockContext) SetLogger(logger *zap.Logger) {
|
||||
ctx.logger = logger
|
||||
}
|
||||
|
||||
// SetEchoContext sets the echo.Context.
|
||||
//
|
||||
// ctx := &api.MockContext{Context: &api.Context{}}
|
||||
// ctx.setEchoContext(c)
|
||||
func (ctx *MockContext) SetEchoContext(c echo.Context) {
|
||||
ctx.Context.echoCtx = c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user