handler

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrToResponse added in v0.3.0

func ErrToResponse(e error) (int, *entities.GoComError)

ErrToResponse checks if the provided error is a GoComError. If yes, status and embedded error message are returned. If no, status is 500 and provided error message are returned.

func ParseIDParam added in v0.3.0

func ParseIDParam(c *gin.Context, name string, p *presenter.Presenter) (entities.ID, bool)

ParseIDParam tries to parse parameter with the given name as an UUID or short ID. On failure, an error is set on the Gin context.

  p := presenter.New()
  id, ok := ParseIDParam(c, "id", p)
  if !ok {
	   return // Response already set on Gin context
  }

func RequireEqualJSON added in v0.3.0

func RequireEqualJSON(t *testing.T, expected any, recorder *httptest.ResponseRecorder)

RequireEqualJSON unmarshals the body from the provided recorder to the same type as expected. Next, it asserts this result against the expected value.

func SetupGinTest added in v0.3.0

func SetupGinTest(t *testing.T, method, path string, params gin.Params, body []byte) (*gin.Context, *httptest.ResponseRecorder)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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