chore: minor godoc refactoring

This commit is contained in:
Julien Neuhart
2023-11-19 15:02:41 +01:00
parent 5c56317d50
commit 4d1a569269
14 changed files with 51 additions and 51 deletions

View File

@@ -44,12 +44,12 @@ type API struct {
srv *echo.Echo
}
// Router is a module interface which adds routes to the API.
// Router is a module interface which adds routes to the [API].
type Router interface {
Routes() ([]Route, error)
}
// Route represents a route from a Router.
// Route represents a route from a [Router].
type Route struct {
// Method is the HTTP method of the route (i.e., GET, POST, etc.).
// Required.
@@ -72,13 +72,13 @@ type Route struct {
Handler echo.HandlerFunc
}
// MiddlewareProvider is a module interface which adds middlewares to the API.
// MiddlewareProvider is a module interface which adds middlewares to the [API].
type MiddlewareProvider interface {
Middlewares() ([]Middleware, error)
}
// MiddlewareStack is a type which helps to determine in which stack the
// middlewares provided by the MiddlewareProvider modules should be located.
// middlewares provided by the [MiddlewareProvider] modules should be located.
type MiddlewareStack uint32
const (
@@ -88,7 +88,7 @@ const (
)
// MiddlewarePriority is a type which helps to determine the execution order of
// middlewares provided by the MiddlewareProvider modules in a stack.
// middlewares provided by the [MiddlewareProvider] modules in a stack.
type MiddlewarePriority uint32
const (
@@ -99,7 +99,7 @@ const (
VeryHighPriority
)
// Middleware is a middleware which can be added to the API's middlewares
// Middleware is a middleware which can be added to the [API]'s middlewares
// chain.
//
// middleware := Middleware{
@@ -126,13 +126,13 @@ const (
// }
type Middleware struct {
// Stack tells in which stack the middleware should be located.
// Default to DefaultStack.
// Default to [DefaultStack].
// Optional.
Stack MiddlewareStack
// Priority tells if the middleware should be positioned high or not in
// its stack.
// Default to VeryLowPriority.
// Default to [VeryLowPriority].
// Optional.
Priority MiddlewarePriority
@@ -149,7 +149,7 @@ type HealthChecker interface {
Checks() ([]health.CheckerOption, error)
}
// Descriptor returns an API's module descriptor.
// Descriptor returns an [API]'s module descriptor.
func (API) Descriptor() gotenberg.ModuleDescriptor {
return gotenberg.ModuleDescriptor{
ID: "api",

View File

@@ -49,7 +49,7 @@ type Context struct {
context.Context
}
// newContext returns a Context by parsing a "multipart/form-data" request.
// newContext returns a [Context] by parsing a "multipart/form-data" request.
func newContext(echoCtx echo.Context, logger *zap.Logger, fs *gotenberg.FileSystem, timeout time.Duration) (*Context, context.CancelFunc, error) {
processCtx, processCancel := context.WithTimeout(context.Background(), timeout)
@@ -185,12 +185,12 @@ func newContext(echoCtx echo.Context, logger *zap.Logger, fs *gotenberg.FileSyst
return ctx, cancel, err
}
// Request returns the http.Request.
// Request returns the [http.Request].
func (ctx Context) Request() *http.Request {
return ctx.echoCtx.Request()
}
// FormData return a FormData.
// FormData return a [FormData].
func (ctx Context) FormData() *FormData {
return &FormData{
values: ctx.values,
@@ -223,7 +223,7 @@ func (ctx *Context) AddOutputPaths(paths ...string) error {
return nil
}
// Log returns the context zap.Logger.
// Log returns the context [zap.Logger].
func (ctx Context) Log() *zap.Logger {
return ctx.logger
}

View File

@@ -13,7 +13,7 @@ type SentinelHTTPError struct {
message string
}
// NewSentinelHTTPError creates a SentinelHTTPError. The message will be sent
// NewSentinelHTTPError creates a [SentinelHTTPError]. The message will be sent
// as the response's body if returned from a handler, so make sure to not leak
// sensible information.
func NewSentinelHTTPError(status int, message string) SentinelHTTPError {
@@ -34,7 +34,7 @@ func (err SentinelHTTPError) HTTPError() (int, string) {
}
// sentinelWrappedError contains both the error which will logged and the
// sidekick SentinelHTTPError.
// sidekick [SentinelHTTPError].
type sentinelWrappedError struct {
error
sentinel SentinelHTTPError
@@ -48,9 +48,9 @@ func (w sentinelWrappedError) HTTPError() (int, string) {
return w.sentinel.HTTPError()
}
// WrapError wraps the given error with a SentinelHTTPError. The wrapped error
// will be displayed in a log, while the SentinelHTTPError will be sent in the
// response.
// WrapError wraps the given error with a [SentinelHTTPError]. The wrapped
// error will be displayed in a log, while the [SentinelHTTPError] will be sent
// in the response.
//
// return api.WrapError(
// // This first error will be logged.

View File

@@ -23,8 +23,8 @@ type FormData struct {
errors error
}
// Validate returns nil or an error related to the FormData values, with a
// SentinelHTTPError (status code 400, errors' details as message) wrapped
// Validate returns nil or an error related to the [FormData] values, with a
// [SentinelHTTPError] (status code 400, errors' details as message) wrapped
// inside.
//
// var foo string

View File

@@ -57,8 +57,8 @@ func httpErrorHandler() echo.HTTPErrorHandler {
}
}
// latencyMiddleware sets the start time in the echo.Context under "startTime".
// Its value will be used later to calculate a request latency.
// latencyMiddleware sets the start time in the [echo.Context] under
// "startTime". Its value will be used later to calculate a request latency.
//
// startTime := c.Get("startTime").(time.Time)
func latencyMiddleware() echo.MiddlewareFunc {
@@ -74,9 +74,9 @@ func latencyMiddleware() echo.MiddlewareFunc {
}
}
// rootPathMiddleware sets the root path in the echo.Context under "rootPath".
// Its value may be used to skip a middleware execution based on a request
// URI.
// rootPathMiddleware sets the root path in the [echo.Context] under
// "rootPath". Its value may be used to skip a middleware execution based on a
// request URI.
//
// rootPath := c.Get("rootPath").(string)
// healthURI := fmt.Sprintf("%s/health", rootPath)
@@ -97,7 +97,7 @@ func rootPathMiddleware(rootPath string) echo.MiddlewareFunc {
}
}
// traceMiddleware sets the request identifier in the echo.Context under
// traceMiddleware sets the request identifier in the [echo.Context] under
// "trace". Its value is either retrieved from the trace header or generated if
// the header is not present / its value is empty.
//
@@ -123,8 +123,8 @@ func traceMiddleware(header string) echo.MiddlewareFunc {
}
}
// loggerMiddleware sets the logger in the echo.Context under "logger" and logs
// a synchronous request result.
// loggerMiddleware sets the logger in the [echo.Context] under "logger" and
// logs a synchronous request result.
//
// logger := c.Get("logger").(*zap.Logger)
func loggerMiddleware(logger *zap.Logger, disableLoggingForPaths []string) echo.MiddlewareFunc {
@@ -196,9 +196,9 @@ func loggerMiddleware(logger *zap.Logger, disableLoggingForPaths []string) echo.
}
// contextMiddleware, a middleware for "multipart/form-data" requests, sets the
// Context and related context.CancelFunc in the echo.Context under "context"
// and "cancel". If the process is synchronous, it also handles the result of a
// "multipart/form-data" request.
// [Context] and related context.CancelFunc in the [echo.Context] under
// "context" and "cancel". If the process is synchronous, it also handles the
// result of a "multipart/form-data" request.
//
// ctx := c.Get("context").(*api.Context)
// cancel := c.Get("cancel").(context.CancelFunc)

View File

@@ -111,8 +111,8 @@ func (c client) send(body io.Reader, headers map[string]string, erroed bool) err
return nil
}
// leveledLogger is wrapper around a zap.Logger which is used by the
// retryablehttp.Client.
// leveledLogger is wrapper around a [zap.Logger] which is used by the
// [retryablehttp.Client].
type leveledLogger struct {
logger *zap.Logger
}

View File

@@ -549,7 +549,7 @@ func TestWebhookMiddlewareAsynchronousProcess(t *testing.T) {
}()
err := webhookMiddleware(tc.mod).Handler(tc.next)(c)
if err != nil && err != api.ErrAsyncProcess {
if err != nil && !errors.Is(err, api.ErrAsyncProcess) {
t.Errorf("test %d: expected no error but got: %v", i, err)
}

View File

@@ -30,7 +30,7 @@ type Webhook struct {
disable bool
}
// Descriptor returns an Webhook's module descriptor.
// Descriptor returns an [Webhook]'s module descriptor.
func (Webhook) Descriptor() gotenberg.ModuleDescriptor {
return gotenberg.ModuleDescriptor{
ID: "webhook",