Documentation
¶
Overview ¶
Package resource helps managing arguments and files for a conversion.
All functions return our standard xerror.Error in case of error.
Index ¶
- Constants
- func GoogleChromeRpccBufferSizeArg(r Resource, config conf.Config) (int64, error)
- func HeaderFooterContents(r Resource, config conf.Config) (string, string, error)
- func MarginArgs(r Resource, config conf.Config) (float64, float64, float64, float64, error)
- func PaperSizeArgs(r Resource, config conf.Config) (float64, float64, error)
- func RemoteURLCustomHTTPHeaders(r Resource) map[string]string
- func ScaleArg(r Resource, config conf.Config) (float64, error)
- func WaitDelayArg(r Resource, config conf.Config) (float64, error)
- func WaitTimeoutArg(r Resource, config conf.Config) (float64, error)
- func WebhookURLCustomHTTPHeaders(r Resource) map[string]string
- func WebhookURLTimeoutArg(r Resource, config conf.Config) (float64, error)
- type ArgKey
- type Resource
- func (r Resource) BoolArg(key ArgKey, defaultValue bool) (bool, error)
- func (r Resource) Close() error
- func (r Resource) DirPath() string
- func (r Resource) Fcontent(filename, defaultValue string) (string, error)
- func (r Resource) Float64Arg(key ArgKey, defaultValue float64, rules ...xassert.RuleFloat64) (float64, error)
- func (r Resource) Fpath(filename string) (string, error)
- func (r Resource) Fpaths(exts ...string) ([]string, error)
- func (r Resource) HasArg(key ArgKey) bool
- func (r Resource) Int64Arg(key ArgKey, defaultValue int64, rules ...xassert.RuleInt64) (int64, error)
- func (r Resource) StringArg(key ArgKey, defaultValue string, rules ...xassert.RuleString) (string, error)
- func (r *Resource) WithArg(key ArgKey, value string)
- func (r *Resource) WithCustomHTTPHeader(key string, value string)
- func (r *Resource) WithFile(filename string, in io.Reader) error
Constants ¶
const ( // RemoteURLCustomHTTPHeaderCanonicalBaseKey is the base key // of custom headers send to the remote URL. RemoteURLCustomHTTPHeaderCanonicalBaseKey string = "Gotenberg-Remoteurl-" // WebhookURLCustomHTTPHeaderCanonicalBaseKey is the base key // of custom headers send to the webhook URL. WebhookURLCustomHTTPHeaderCanonicalBaseKey string = "Gotenberg-Webhookurl-" )
const TemporaryDirectory string = "tmp"
TemporaryDirectory is the directory where all the resources directory are located.
Variables ¶
This section is empty.
Functions ¶
func GoogleChromeRpccBufferSizeArg ¶
GoogleChromeRpccBufferSizeArg is a helper for retrieving the "googleChromeRpccBufferSize" argument as int64.
It also validates it against the application configuration.
func HeaderFooterContents ¶
HeaderFooterContents is a helper for retrieving the content of the files "header.html" and "footer.html".
func MarginArgs ¶
MarginArgs is a helper for retrieving the "marginTop", "marginBottom", "marginLeft" and "marginRight" arguments as float64.
func PaperSizeArgs ¶
PaperSizeArgs is a helper for retrieving the "paperWidth" and "paperHeight" arguments as float64.
func RemoteURLCustomHTTPHeaders ¶
RemoteURLCustomHTTPHeaders is a helper for retrieving the custom headers for the URL conversion.
func WaitDelayArg ¶
WaitDelayArg is a helper for retrieving the "waitDelay" argument as float64.
It also validates it against the application configuration.
func WaitTimeoutArg ¶
WaitTimeoutArg is a helper for retrieving the "waitTimeout" argument as float64.
It also validates it against the application configuration.
func WebhookURLCustomHTTPHeaders ¶
WebhookURLCustomHTTPHeaders is a helper for retrieving the custom headers for the webhook URL.
Types ¶
type ArgKey ¶
type ArgKey string
ArgKey is a type for arguments' keys.
const ( // ResultFilenameArgKey is the key // of the argument "resultFilename". ResultFilenameArgKey ArgKey = "resultFilename" // WaitTimeoutArgKey is the key // of the argument "waitTimeout". WaitTimeoutArgKey ArgKey = "waitTimeout" // WebhookURLArgKey is the key // of the argument "webhookURL". WebhookURLArgKey ArgKey = "webhookURL" // WebhookURLTimeoutArgKey is the key // of the argument "webhookURLTimeout". WebhookURLTimeoutArgKey ArgKey = "webhookURLTimeout" // RemoteURLArgKey is the key // of the argument "remoteURL". RemoteURLArgKey ArgKey = "remoteURL" // WaitDelayArgKey is the key // of the argument "waitDelay". WaitDelayArgKey ArgKey = "waitDelay" // PaperWidthArgKey is the key // of the argument "paperWidth". PaperWidthArgKey ArgKey = "paperWidth" // PaperHeightArgKey is the key // of the argument "paperHeight". PaperHeightArgKey ArgKey = "paperHeight" // MarginTopArgKey is the key // of the argument "marginTop". MarginTopArgKey ArgKey = "marginTop" // MarginBottomArgKey is the key // of the argument "marginBottom". MarginBottomArgKey ArgKey = "marginBottom" // MarginLeftArgKey is the key // of the argument "marginLeft". MarginLeftArgKey ArgKey = "marginLeft" // MarginRightArgKey is the key // of the argument "marginRight". MarginRightArgKey ArgKey = "marginRight" // LandscapeArgKey is the key // of the argument "landscape". LandscapeArgKey ArgKey = "landscape" // PageRangesArgKey is the key // of the argument "pageRanges". PageRangesArgKey ArgKey = "pageRanges" // GoogleChromeRpccBufferSizeArgKey is the key // of the argument "googleChromeRpccBufferSize". GoogleChromeRpccBufferSizeArgKey ArgKey = "googleChromeRpccBufferSize" // ScaleArgKey is the key // of the argument "scale". ScaleArgKey ArgKey = "scale" )
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource helps managing arguments and files for a conversion.
func (Resource) BoolArg ¶
BoolArg returns the boolean representation of the argument identified by given key.
It works in the same manner as xassert.Bool.
func (Resource) Fcontent ¶
Fcontent returns the string content of the given filename.
If filename does not exist within the Resource, returns the default value.
func (Resource) Float64Arg ¶
func (r Resource) Float64Arg(key ArgKey, defaultValue float64, rules ...xassert.RuleFloat64) (float64, error)
Float64Arg returns the float64 representation of the argument identified by given key.
It works in the same manner as xassert.Float64.
func (Resource) Fpath ¶
Fpath returns the path of the given filename. This filename should exist whithin the Resource.
func (Resource) Fpaths ¶
Fpaths returns the paths of the files having one of the given file extensions.
It should found at least one path.
func (Resource) HasArg ¶
HasArg returns true if given key exists among the Resource and its value is not empty.
func (Resource) Int64Arg ¶
func (r Resource) Int64Arg(key ArgKey, defaultValue int64, rules ...xassert.RuleInt64) (int64, error)
Int64Arg returns the int64 representation of the argument identified by given key.
It works in the same manner as xassert.Int64.
func (Resource) StringArg ¶
func (r Resource) StringArg(key ArgKey, defaultValue string, rules ...xassert.RuleString) (string, error)
StringArg returns the value of the argument identified by given key.
It works in the same manner as xassert.String.
func (*Resource) WithCustomHTTPHeader ¶
WithCustomHTTPHeader add a new custom header to the Resource. Given key should be in canonical format.