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: 12 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 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 User3451555716View

type User3451555716View struct {
	ID   int       `json:"id,omitempty"`
	UUID uuid.UUID `json:"uuid,omitempty"`
}

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

func NewUser3451555716View

func NewUser3451555716View(e *ent.User) *User3451555716View

func (User3451555716View) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*User3451555716View) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type User3451555716Views

type User3451555716Views []*User3451555716View

func NewUser3451555716Views

func NewUser3451555716Views(es []*ent.User) User3451555716Views

func (User3451555716Views) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*User3451555716Views) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type UserCreateRequest

type UserCreateRequest struct {
	UUID *uuid.UUID `json:"uuid"`
}

Payload of a ent.User create request.

func (UserCreateRequest) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*UserCreateRequest) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type UserHandler

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

UserHandler handles http crud operations on ent.User.

func NewUserHandler

func NewUserHandler(c *ent.Client, l *zap.Logger) *UserHandler

func (UserHandler) Create

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

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

func (UserHandler) Delete

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

Delete removes a ent.User from the database.

func (*UserHandler) List

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

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

func (*UserHandler) MountCreateRoute

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

func (*UserHandler) MountDeleteRoute

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

func (*UserHandler) MountListRoute

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

func (*UserHandler) MountReadRoute

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

func (*UserHandler) MountRoutes

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

func (*UserHandler) MountUpdateRoute

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

func (*UserHandler) Read

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

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

func (UserHandler) Update

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

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

type UserUpdateRequest

type UserUpdateRequest struct {
	UUID *uuid.UUID `json:"uuid"`
}

Payload of a ent.User update request.

func (UserUpdateRequest) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (*UserUpdateRequest) UnmarshalEasyJSON

func (v *UserUpdateRequest) 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