controller

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ID   int    `json:"id" example:"1"`
	Name string `json:"name" example:"admin name"`
}

Admin example

type Controller

type Controller struct {
}

Controller example

func NewController

func NewController() *Controller

NewController example

func (*Controller) AddAccount

func (c *Controller) AddAccount(addAccount *model.AddAccount, w http.ResponseWriter, r *http.Request) (*model.Account, int, error)

AddAccount godoc @Summary Add an account @Description add by json account @Tags accounts @Accept json @Produce json @Param account body model.AddAccount true "Add account" @Success 200 {object} model.Account @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error @Router /accounts [post]

func (*Controller) AttributeExample

func (c *Controller) AttributeExample(w http.ResponseWriter, r *http.Request) (string, int, error)

AttributeExample godoc @Summary attribute example @Description attribute @Tags example @Accept json @Produce json @Param enumstring query string false "string enums" Enums(A, B, C) @Param enumint query int false "int enums" Enums(1, 2, 3) @Param enumnumber query number false "int enums" Enums(1.1, 1.2, 1.3) @Param string query string false "string valid" minlength(5) maxlength(10) @Param int query int false "int valid" minimum(1) maximum(10) @Param default query string false "string default" default(A) @Success 200 {string} string "answer" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok"

func (*Controller) Auth

func (c *Controller) Auth(m any, w http.ResponseWriter, r *http.Request) (*model.Admin, int, error)

Auth godoc @Summary Auth admin @Description get admin info @Tags accounts,admin @Accept json @Produce json @Success 200 @Failure 400 {object} httputil.Error @Failure 401 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error @Security ApiKeyAuth @Router /admin/auth [post]

func (*Controller) CalcExample

func (c *Controller) CalcExample(w http.ResponseWriter, r *http.Request) (string, int, error)

CalcExample godoc @Summary calc example @Description plus @Tags example @Accept json @Produce json @Param val1 query int true "used for calc" @Param val2 query int true "used for calc" @Success 200 {integer} string "answer" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok"

func (*Controller) ChiRoutes

func (c *Controller) ChiRoutes() chi.Router

func (*Controller) DeleteAccount

func (c *Controller) DeleteAccount(w http.ResponseWriter, r *http.Request)

DeleteAccount godoc @Summary Delete an account @Description Delete by account ID @Tags accounts @Accept json @Produce json @Success 204 {object} model.Account @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error

func (*Controller) HeaderExample

func (c *Controller) HeaderExample(w http.ResponseWriter, r *http.Request) (string, int, error)

HeaderExample godoc @Summary custome header example @Description custome header @Tags example @Accept json @Produce json @Param Authorization header string true "Authentication header" @Success 200 {string} string "answer" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok"

func (*Controller) ListAccounts

func (c *Controller) ListAccounts(w http.ResponseWriter, r *http.Request) (*[]model.Account, int, error)

ListAccounts godoc @Summary List accounts @Description get accounts @Tags accounts @Accept json @Produce json @Param q query string false "name search by q" Format(email) @Success 201 {array} model.Account @Success 202 {array} model.Account @Success 203 {array} model.Account @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error @Router /accounts [get]

func (*Controller) ListBottles

func (c *Controller) ListBottles(w http.ResponseWriter, r *http.Request) (*[]model.Bottle, int, *httputil.Error)

ListBottles godoc @Summary List bottles @Description get bottles @Tags bottles @Accept json @Produce json @Success 200,201,202 @Failure 400,404,500

func (*Controller) PathParamsExample

func (c *Controller) PathParamsExample(w http.ResponseWriter, r *http.Request) (string, int, error)

PathParamsExample godoc @Summary path params example @Description path params @Tags example @Accept json @Produce json @Param group_id path int true "Group ID" @Param account_id path int true "Account ID" @Success 200 {string} string "answer" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok"

func (*Controller) PingExample

func (c *Controller) PingExample(w http.ResponseWriter, r *http.Request) (string, int, error)

PingExample godoc @Summary ping example @Description do ping @Tags example @Accept json @Produce json @Success 200 {string} string "pong" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok"

func (*Controller) PostExample

func (c *Controller) PostExample(account *model.Account, w http.ResponseWriter, r *http.Request) (*model.Account2, int, *httputil.Error)

PostExample godoc @Summary post request example @Description post request example

func (*Controller) SecuritiesExample

func (c *Controller) SecuritiesExample(w http.ResponseWriter, r *http.Request) (string, int, error)

SecuritiesExample godoc @Summary custome header example @Description custome header @Tags example @Accept json @Produce json @Param Authorization header string true "Authentication header" @Success 200 {string} string "answer" @Failure 400 {string} string "ok" @Failure 404 {string} string "ok" @Failure 500 {string} string "ok" @Security ApiKeyAuth @Security OAuth2Implicit[admin, write]

func (*Controller) ShowAccount

func (c *Controller) ShowAccount(w http.ResponseWriter, r *http.Request) (*model.Account, int, error)

ShowAccount godoc @Summary Show an account @Description get string by ID @Tags accounts @Accept json @Produce json @Param id path int true "Account ID" @Success 200 {object} model.Account @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error

func (*Controller) ShowBottle

func (c *Controller) ShowBottle(w http.ResponseWriter, r *http.Request) (*model.Bottle, int, error)

ShowBottle godoc @Summary Show a bottle @Description get string by ID @ID get-string-by-int @Tags bottles @Accept json @Produce json @Param id path int true "Bottle ID" @Success 200 {object} model.Bottle @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error

func (*Controller) UpdateAccount

func (c *Controller) UpdateAccount(w http.ResponseWriter, r *http.Request)

UpdateAccount godoc @Summary Update an account @Description Update by json account @Tags accounts @Accept json @Produce json @Param id path int true "Account ID" @Param account body model.UpdateAccount true "Update account" @Success 200 {object} model.Account @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error @Router /accounts/{id} [patch]

func (*Controller) UploadAccountImage

func (c *Controller) UploadAccountImage(w http.ResponseWriter, r *http.Request)

UploadAccountImage godoc @Summary Upload account image @Description Upload file @Tags accounts @Accept multipart/form-data @Produce json @Param id path int true "Account ID" @Param file formData file true "account image" @Success 200 {object} Message @Failure 400 {object} httputil.Error @Failure 404 {object} httputil.Error @Failure 500 {object} httputil.Error

type Message

type Message struct {
	Message string `json:"message" example:"message"`
}

Message example

type Message2

type Message2 struct {
	Message string `json:"message" example:"message"`
}

Jump to

Keyboard shortcuts

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