http

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, msg interface{}) (int, error)

func Conflict

func Conflict(w http.ResponseWriter, msg interface{}) (int, error)

func Forbidden

func Forbidden(w http.ResponseWriter, msg interface{}) (int, error)

func InternalServerError

func InternalServerError(w http.ResponseWriter, msg interface{}) (int, error)

func MountRoutes

func MountRoutes(c *ent.Client, l *zap.Logger, r chi.Router)

MountRoutes mounts all generated routes on the given router.

func NewHandler

func NewHandler(c *ent.Client, l *zap.Logger) chi.Router

NewHandler returns a ready to use handler with all generated endpoints mounted.

func NotFound

func NotFound(w http.ResponseWriter, msg interface{}) (int, error)

func Unauthorized

func Unauthorized(w http.ResponseWriter, msg interface{}) (int, error)

Types

type Category4094953247View

type Category4094953247View struct {
	ID   uint64 `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Category4094953247View represents the data serialized for the following serialization group combinations: [] [owner pet pet:owner]

func NewCategory4094953247View

func NewCategory4094953247View(e *ent.Category) *Category4094953247View

func (Category4094953247View) MarshalEasyJSON

func (v Category4094953247View) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Category4094953247View) UnmarshalEasyJSON

func (v *Category4094953247View) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Category4094953247Views

type Category4094953247Views []*Category4094953247View

func NewCategory4094953247Views

func NewCategory4094953247Views(es []*ent.Category) Category4094953247Views

func (Category4094953247Views) MarshalEasyJSON

func (v Category4094953247Views) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Category4094953247Views) UnmarshalEasyJSON

func (v *Category4094953247Views) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CategoryCreateRequest

type CategoryCreateRequest struct {
	Name *string  `json:"name"`
	Pets []string `json:"pets"`
}

Payload of a ent.Category create request.

func (CategoryCreateRequest) MarshalEasyJSON

func (v CategoryCreateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CategoryCreateRequest) UnmarshalEasyJSON

func (v *CategoryCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CategoryHandler

type CategoryHandler struct {
	// contains filtered or unexported fields
}

CategoryHandler handles http crud operations on ent.Category.

func NewCategoryHandler

func NewCategoryHandler(c *ent.Client, l *zap.Logger) *CategoryHandler

func (CategoryHandler) Create

Create creates a new ent.Category and stores it in the database.

func (CategoryHandler) Delete

Delete removes a ent.Category from the database.

func (*CategoryHandler) List

Read fetches the ent.Category identified by a given url-parameter from the database and returns it to the client.

func (*CategoryHandler) MountCreateRoute

func (h *CategoryHandler) MountCreateRoute(r chi.Router) *CategoryHandler

func (*CategoryHandler) MountDeleteRoute

func (h *CategoryHandler) MountDeleteRoute(r chi.Router) *CategoryHandler

func (*CategoryHandler) MountListRoute

func (h *CategoryHandler) MountListRoute(r chi.Router) *CategoryHandler

func (*CategoryHandler) MountPetsRoute

func (h *CategoryHandler) MountPetsRoute(r chi.Router) *CategoryHandler

func (*CategoryHandler) MountReadRoute

func (h *CategoryHandler) MountReadRoute(r chi.Router) *CategoryHandler

func (*CategoryHandler) MountRoutes

func (h *CategoryHandler) MountRoutes(r chi.Router)

func (*CategoryHandler) MountUpdateRoute

func (h *CategoryHandler) MountUpdateRoute(r chi.Router) *CategoryHandler

func (CategoryHandler) Pets

Pets fetches the ent.pets attached to the ent.Category identified by a given url-parameter from the database and renders it to the client.

func (*CategoryHandler) Read

Read fetches the ent.Category identified by a given url-parameter from the database and renders it to the client.

func (CategoryHandler) Update

Update updates a given ent.Category and saves the changes to the database.

type CategoryUpdateRequest

type CategoryUpdateRequest struct {
	Name *string  `json:"name"`
	Pets []string `json:"pets"`
}

Payload of a ent.Category update request.

func (CategoryUpdateRequest) MarshalEasyJSON

func (v CategoryUpdateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CategoryUpdateRequest) UnmarshalEasyJSON

func (v *CategoryUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Collar1522160880View

type Collar1522160880View struct {
	ID    int          `json:"id,omitempty"`
	Color collar.Color `json:"color,omitempty"`
}

Collar1522160880View represents the data serialized for the following serialization group combinations: [] [owner pet pet:owner]

func NewCollar1522160880View

func NewCollar1522160880View(e *ent.Collar) *Collar1522160880View

func (Collar1522160880View) MarshalEasyJSON

func (v Collar1522160880View) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Collar1522160880View) UnmarshalEasyJSON

func (v *Collar1522160880View) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Collar1522160880Views

type Collar1522160880Views []*Collar1522160880View

func NewCollar1522160880Views

func NewCollar1522160880Views(es []*ent.Collar) Collar1522160880Views

func (Collar1522160880Views) MarshalEasyJSON

func (v Collar1522160880Views) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Collar1522160880Views) UnmarshalEasyJSON

func (v *Collar1522160880Views) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CollarCreateRequest

type CollarCreateRequest struct {
	Color *collar.Color `json:"color"`
	Pet   *string       `json:"pet"`
}

Payload of a ent.Collar create request.

func (CollarCreateRequest) MarshalEasyJSON

func (v CollarCreateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CollarCreateRequest) UnmarshalEasyJSON

func (v *CollarCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type CollarHandler

type CollarHandler struct {
	// contains filtered or unexported fields
}

CollarHandler handles http crud operations on ent.Collar.

func NewCollarHandler

func NewCollarHandler(c *ent.Client, l *zap.Logger) *CollarHandler

func (CollarHandler) Create

func (h CollarHandler) Create(w http.ResponseWriter, r *http.Request)

Create creates a new ent.Collar and stores it in the database.

func (CollarHandler) Delete

func (h CollarHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a ent.Collar from the database.

func (*CollarHandler) List

func (h *CollarHandler) List(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Collar identified by a given url-parameter from the database and returns it to the client.

func (*CollarHandler) MountCreateRoute

func (h *CollarHandler) MountCreateRoute(r chi.Router) *CollarHandler

func (*CollarHandler) MountDeleteRoute

func (h *CollarHandler) MountDeleteRoute(r chi.Router) *CollarHandler

func (*CollarHandler) MountListRoute

func (h *CollarHandler) MountListRoute(r chi.Router) *CollarHandler

func (*CollarHandler) MountPetRoute

func (h *CollarHandler) MountPetRoute(r chi.Router) *CollarHandler

func (*CollarHandler) MountReadRoute

func (h *CollarHandler) MountReadRoute(r chi.Router) *CollarHandler

func (*CollarHandler) MountRoutes

func (h *CollarHandler) MountRoutes(r chi.Router)

func (*CollarHandler) MountUpdateRoute

func (h *CollarHandler) MountUpdateRoute(r chi.Router) *CollarHandler

func (CollarHandler) Pet

Pet fetches the ent.pet attached to the ent.Collar identified by a given url-parameter from the database and renders it to the client.

func (*CollarHandler) Read

func (h *CollarHandler) Read(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Collar identified by a given url-parameter from the database and renders it to the client.

func (CollarHandler) Update

func (h CollarHandler) Update(w http.ResponseWriter, r *http.Request)

Update updates a given ent.Collar and saves the changes to the database.

type CollarUpdateRequest

type CollarUpdateRequest struct {
	Color *collar.Color `json:"color"`
	Pet   *string       `json:"pet"`
}

Payload of a ent.Collar update request.

func (CollarUpdateRequest) MarshalEasyJSON

func (v CollarUpdateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*CollarUpdateRequest) UnmarshalEasyJSON

func (v *CollarUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type ErrResponse

type ErrResponse struct {
	Code   int         `json:"code"`             // http response status code
	Status string      `json:"status"`           // user-level status message
	Errors interface{} `json:"errors,omitempty"` // application-level error
}

Basic HTTP Error Response

func (ErrResponse) MarshalEasyJSON

func (v ErrResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ErrResponse) MarshalToHTTPResponseWriter

func (e ErrResponse) MarshalToHTTPResponseWriter(w http.ResponseWriter) (int, error)

func (*ErrResponse) UnmarshalEasyJSON

func (v *ErrResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Owner139708381View

type Owner139708381View struct {
	ID   uuid.UUID `json:"id,omitempty"`
	Name string    `json:"name,omitempty"`
	Age  int       `json:"age,omitempty"`
}

Owner139708381View represents the data serialized for the following serialization group combinations: [] [owner pet pet:owner]

func NewOwner139708381View

func NewOwner139708381View(e *ent.Owner) *Owner139708381View

func (Owner139708381View) MarshalEasyJSON

func (v Owner139708381View) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Owner139708381View) UnmarshalEasyJSON

func (v *Owner139708381View) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Owner139708381Views

type Owner139708381Views []*Owner139708381View

func NewOwner139708381Views

func NewOwner139708381Views(es []*ent.Owner) Owner139708381Views

func (Owner139708381Views) MarshalEasyJSON

func (v Owner139708381Views) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Owner139708381Views) UnmarshalEasyJSON

func (v *Owner139708381Views) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type OwnerCreateRequest

type OwnerCreateRequest struct {
	Name *string  `json:"name"`
	Age  *int     `json:"age"`
	Pets []string `json:"pets"`
}

Payload of a ent.Owner create request.

func (OwnerCreateRequest) MarshalEasyJSON

func (v OwnerCreateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*OwnerCreateRequest) UnmarshalEasyJSON

func (v *OwnerCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type OwnerHandler

type OwnerHandler struct {
	// contains filtered or unexported fields
}

OwnerHandler handles http crud operations on ent.Owner.

func NewOwnerHandler

func NewOwnerHandler(c *ent.Client, l *zap.Logger) *OwnerHandler

func (OwnerHandler) Create

func (h OwnerHandler) Create(w http.ResponseWriter, r *http.Request)

Create creates a new ent.Owner and stores it in the database.

func (OwnerHandler) Delete

func (h OwnerHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a ent.Owner from the database.

func (*OwnerHandler) List

func (h *OwnerHandler) List(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Owner identified by a given url-parameter from the database and returns it to the client.

func (*OwnerHandler) MountCreateRoute

func (h *OwnerHandler) MountCreateRoute(r chi.Router) *OwnerHandler

func (*OwnerHandler) MountDeleteRoute

func (h *OwnerHandler) MountDeleteRoute(r chi.Router) *OwnerHandler

func (*OwnerHandler) MountListRoute

func (h *OwnerHandler) MountListRoute(r chi.Router) *OwnerHandler

func (*OwnerHandler) MountPetsRoute

func (h *OwnerHandler) MountPetsRoute(r chi.Router) *OwnerHandler

func (*OwnerHandler) MountReadRoute

func (h *OwnerHandler) MountReadRoute(r chi.Router) *OwnerHandler

func (*OwnerHandler) MountRoutes

func (h *OwnerHandler) MountRoutes(r chi.Router)

func (*OwnerHandler) MountUpdateRoute

func (h *OwnerHandler) MountUpdateRoute(r chi.Router) *OwnerHandler

func (OwnerHandler) Pets

Pets fetches the ent.pets attached to the ent.Owner identified by a given url-parameter from the database and renders it to the client.

func (*OwnerHandler) Read

func (h *OwnerHandler) Read(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Owner identified by a given url-parameter from the database and renders it to the client.

func (OwnerHandler) Update

func (h OwnerHandler) Update(w http.ResponseWriter, r *http.Request)

Update updates a given ent.Owner and saves the changes to the database.

type OwnerUpdateRequest

type OwnerUpdateRequest struct {
	Name *string  `json:"name"`
	Age  *int     `json:"age"`
	Pets []string `json:"pets"`
}

Payload of a ent.Owner update request.

func (OwnerUpdateRequest) MarshalEasyJSON

func (v OwnerUpdateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*OwnerUpdateRequest) UnmarshalEasyJSON

func (v *OwnerUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Pet1876743790View

type Pet1876743790View struct {
	ID      string              `json:"id,omitempty"`
	Name    string              `json:"name,omitempty"`
	Age     int                 `json:"age,omitempty"`
	Owner   *Owner139708381View `json:"owner,omitempty"`
	Friends Pet359800019Views   `json:"friends,omitempty"`
}

Pet1876743790View represents the data serialized for the following serialization group combinations: [owner pet pet:owner]

func NewPet1876743790View

func NewPet1876743790View(e *ent.Pet) *Pet1876743790View

func (Pet1876743790View) MarshalEasyJSON

func (v Pet1876743790View) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Pet1876743790View) UnmarshalEasyJSON

func (v *Pet1876743790View) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Pet1876743790Views

type Pet1876743790Views []*Pet1876743790View

func NewPet1876743790Views

func NewPet1876743790Views(es []*ent.Pet) Pet1876743790Views

func (Pet1876743790Views) MarshalEasyJSON

func (v Pet1876743790Views) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Pet1876743790Views) UnmarshalEasyJSON

func (v *Pet1876743790Views) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Pet359800019View

type Pet359800019View struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Age  int    `json:"age,omitempty"`
}

Pet359800019View represents the data serialized for the following serialization group combinations: []

func NewPet359800019View

func NewPet359800019View(e *ent.Pet) *Pet359800019View

func (Pet359800019View) MarshalEasyJSON

func (v Pet359800019View) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Pet359800019View) UnmarshalEasyJSON

func (v *Pet359800019View) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type Pet359800019Views

type Pet359800019Views []*Pet359800019View

func NewPet359800019Views

func NewPet359800019Views(es []*ent.Pet) Pet359800019Views

func (Pet359800019Views) MarshalEasyJSON

func (v Pet359800019Views) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Pet359800019Views) UnmarshalEasyJSON

func (v *Pet359800019Views) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type PetCreateRequest

type PetCreateRequest struct {
	Name       *string    `json:"name"`
	Age        *int       `json:"age"`
	Collar     *int       `json:"collar"`
	Categories []uint64   `json:"categories"`
	Owner      *uuid.UUID `json:"owner"`
	Friends    []string   `json:"friends"`
}

Payload of a ent.Pet create request.

func (PetCreateRequest) MarshalEasyJSON

func (v PetCreateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*PetCreateRequest) UnmarshalEasyJSON

func (v *PetCreateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type PetHandler

type PetHandler struct {
	// contains filtered or unexported fields
}

PetHandler handles http crud operations on ent.Pet.

func NewPetHandler

func NewPetHandler(c *ent.Client, l *zap.Logger) *PetHandler

func (PetHandler) Categories

func (h PetHandler) Categories(w http.ResponseWriter, r *http.Request)

Categories fetches the ent.categories attached to the ent.Pet identified by a given url-parameter from the database and renders it to the client.

func (PetHandler) Collar

func (h PetHandler) Collar(w http.ResponseWriter, r *http.Request)

Collar fetches the ent.collar attached to the ent.Pet identified by a given url-parameter from the database and renders it to the client.

func (PetHandler) Create

func (h PetHandler) Create(w http.ResponseWriter, r *http.Request)

Create creates a new ent.Pet and stores it in the database.

func (PetHandler) Delete

func (h PetHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a ent.Pet from the database.

func (PetHandler) Friends

func (h PetHandler) Friends(w http.ResponseWriter, r *http.Request)

Friends fetches the ent.friends attached to the ent.Pet identified by a given url-parameter from the database and renders it to the client.

func (*PetHandler) List

func (h *PetHandler) List(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Pet identified by a given url-parameter from the database and returns it to the client.

func (*PetHandler) MountCategoriesRoute

func (h *PetHandler) MountCategoriesRoute(r chi.Router) *PetHandler

func (*PetHandler) MountCollarRoute

func (h *PetHandler) MountCollarRoute(r chi.Router) *PetHandler

func (*PetHandler) MountCreateRoute

func (h *PetHandler) MountCreateRoute(r chi.Router) *PetHandler

func (*PetHandler) MountDeleteRoute

func (h *PetHandler) MountDeleteRoute(r chi.Router) *PetHandler

func (*PetHandler) MountFriendsRoute

func (h *PetHandler) MountFriendsRoute(r chi.Router) *PetHandler

func (*PetHandler) MountListRoute

func (h *PetHandler) MountListRoute(r chi.Router) *PetHandler

func (*PetHandler) MountOwnerRoute

func (h *PetHandler) MountOwnerRoute(r chi.Router) *PetHandler

func (*PetHandler) MountReadRoute

func (h *PetHandler) MountReadRoute(r chi.Router) *PetHandler

func (*PetHandler) MountRoutes

func (h *PetHandler) MountRoutes(r chi.Router)

func (*PetHandler) MountUpdateRoute

func (h *PetHandler) MountUpdateRoute(r chi.Router) *PetHandler

func (PetHandler) Owner

func (h PetHandler) Owner(w http.ResponseWriter, r *http.Request)

Owner fetches the ent.owner attached to the ent.Pet identified by a given url-parameter from the database and renders it to the client.

func (*PetHandler) Read

func (h *PetHandler) Read(w http.ResponseWriter, r *http.Request)

Read fetches the ent.Pet identified by a given url-parameter from the database and renders it to the client.

func (PetHandler) Update

func (h PetHandler) Update(w http.ResponseWriter, r *http.Request)

Update updates a given ent.Pet and saves the changes to the database.

type PetUpdateRequest

type PetUpdateRequest struct {
	Name       *string    `json:"name"`
	Age        *int       `json:"age"`
	Collar     *int       `json:"collar"`
	Categories []uint64   `json:"categories"`
	Owner      *uuid.UUID `json:"owner"`
	Friends    []string   `json:"friends"`
}

Payload of a ent.Pet update request.

func (PetUpdateRequest) MarshalEasyJSON

func (v PetUpdateRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*PetUpdateRequest) UnmarshalEasyJSON

func (v *PetUpdateRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

Jump to

Keyboard shortcuts

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