renderror

package
v2.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 8 Imported by: 0 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(rendC *render.Render) func(http.Handler) http.Handler

Handler is middleware that renders error pages based on response status codes

Types

type RenderClient

type RenderClient interface {
	BuildHTML(w io.Writer, status int, templateName string, pageModel interface{}) error
	SetError(w io.Writer, status int, errorModel model.ErrorResponse) error
}

type RenderClientMock

type RenderClientMock struct {
	// BuildHTMLFunc mocks the BuildHTML method.
	BuildHTMLFunc func(w io.Writer, status int, templateName string, pageModel interface{}) error

	// SetErrorFunc mocks the SetError method.
	SetErrorFunc func(w io.Writer, status int, errorModel model.ErrorResponse) error
	// contains filtered or unexported fields
}

RenderClientMock is a mock implementation of RenderClient.

    func TestSomethingThatUsesRenderClient(t *testing.T) {

        // make and configure a mocked RenderClient
        mockedRenderClient := &RenderClientMock{
            BuildHTMLFunc: func(w io.Writer, status int, templateName string, pageModel interface{}) error {
	               panic("mock out the BuildHTML method")
            },
            SetErrorFunc: func(w io.Writer, status int, errorModel model.ErrorResponse) error {
	               panic("mock out the SetError method")
            },
        }

        // use mockedRenderClient in code that requires RenderClient
        // and then make assertions.

    }

func (*RenderClientMock) BuildHTML

func (mock *RenderClientMock) BuildHTML(w io.Writer, status int, templateName string, pageModel interface{}) error

BuildHTML calls BuildHTMLFunc.

func (*RenderClientMock) BuildHTMLCalls

func (mock *RenderClientMock) BuildHTMLCalls() []struct {
	W            io.Writer
	Status       int
	TemplateName string
	PageModel    interface{}
}

BuildHTMLCalls gets all the calls that were made to BuildHTML. Check the length with:

len(mockedRenderClient.BuildHTMLCalls())

func (*RenderClientMock) SetError

func (mock *RenderClientMock) SetError(w io.Writer, status int, errorModel model.ErrorResponse) error

SetError calls SetErrorFunc.

func (*RenderClientMock) SetErrorCalls

func (mock *RenderClientMock) SetErrorCalls() []struct {
	W          io.Writer
	Status     int
	ErrorModel model.ErrorResponse
}

SetErrorCalls gets all the calls that were made to SetError. Check the length with:

len(mockedRenderClient.SetErrorCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL