http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupCreateRequest

type GroupCreateRequest struct {
	Name  *string `json:"name"`
	Users []int   `json:"users"`
	Admin *int    `json:"admin"`
}

Payload of a ent.Group create request.

type GroupHandler

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

GroupHandler handles http crud operations on ent.Group.

func NewGroupHandler

func NewGroupHandler(c *ent.Client, l *zap.Logger, v *validator.Validate) *GroupHandler

func (GroupHandler) Admin

func (h GroupHandler) Admin(w http.ResponseWriter, r *http.Request)

Admin fetches the ent.admin attached to the ent.Group identified by a given url-parameter from the database and renders it to the client.

func (GroupHandler) Create

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

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

func (GroupHandler) Delete

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

Delete removes a ent.Group from the database.

func (*GroupHandler) List

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

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

func (*GroupHandler) Mount

func (h *GroupHandler) Mount(r chi.Router, rs Routes)

RegisterHandlers registers the generated handlers on the given chi router.

func (*GroupHandler) Read

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

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

func (GroupHandler) Update

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

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

func (GroupHandler) Users

func (h GroupHandler) Users(w http.ResponseWriter, r *http.Request)

Users fetches the ent.users attached to the ent.Group identified by a given url-parameter from the database and renders it to the client.

type GroupUpdateRequest

type GroupUpdateRequest struct {
	Name  *string `json:"name"`
	Users []int   `json:"users"`
	Admin *int    `json:"admin"`
}

Payload of a ent.Group update request.

type PetCreateRequest

type PetCreateRequest struct {
	Name    *string `json:"name"`
	Friends []int   `json:"friends"`
	Owner   *int    `json:"owner"`
}

Payload of a ent.Pet create request.

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, v *validator.Validate) *PetHandler

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) Mount

func (h *PetHandler) Mount(r chi.Router, rs Routes)

RegisterHandlers registers the generated handlers on the given chi router.

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"`
	Friends []int   `json:"friends"`
	Owner   *int    `json:"owner"`
}

Payload of a ent.Pet update request.

type Routes

type Routes uint8

Bitmask to configure which routes to register.

const (
	GroupCreate Routes = 1 << iota
	GroupRead
	GroupUpdate
	GroupDelete
	GroupList
	GroupUsers
	GroupAdmin
	GroupRoutes = 1<<iota - 1
)
const (
	PetCreate Routes = 1 << iota
	PetRead
	PetUpdate
	PetDelete
	PetList
	PetFriends
	PetOwner
	PetRoutes = 1<<iota - 1
)
const (
	UserCreate Routes = 1 << iota
	UserRead
	UserUpdate
	UserDelete
	UserList
	UserPets
	UserFriends
	UserGroups
	UserManage
	UserRoutes = 1<<iota - 1
)

type UserCreateRequest

type UserCreateRequest struct {
	Age     *int    `json:"age"`
	Name    *string `json:"name" validate:"alpha,min=3"`
	Pets    []int   `json:"pets"`
	Friends []int   `json:"friends"`
	Groups  []int   `json:"groups"`
	Manage  []int   `json:"manage"`
}

Payload of a ent.User create request.

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, v *validator.Validate) *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) Friends

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

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

func (UserHandler) Groups

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

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

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) Manage

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

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

func (*UserHandler) Mount

func (h *UserHandler) Mount(r chi.Router, rs Routes)

RegisterHandlers registers the generated handlers on the given chi router.

func (UserHandler) Pets

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

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

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 {
	Age     *int    `json:"age"`
	Name    *string `json:"name" validate:"alpha,min=3"`
	Pets    []int   `json:"pets"`
	Friends []int   `json:"friends"`
	Groups  []int   `json:"groups"`
	Manage  []int   `json:"manage"`
}

Payload of a ent.User update request.

Jump to

Keyboard shortcuts

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