document

package
v0.0.0-...-488514f Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDocument

func CreateDocument(w http.ResponseWriter, r *http.Request, endpoint string)

CreateDocument godoc @Summary Create a new document @Description Create a new document @Tags documents @Accept json @Produce json @Param document body Request true "Document" @Param file formData file false "Document file" @Success 201 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents [post]

func Ctx

func Ctx(next http.Handler) http.Handler

func DeleteDocument

func DeleteDocument(w http.ResponseWriter, r *http.Request)

DeleteDocument godoc @Summary Delete a document @Description Delete a document @Tags documents @Accept json @Produce json @Param id path int true "Document ID" @Success 204 @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/{id} [delete]

func GetDocument

func GetDocument(w http.ResponseWriter, r *http.Request)

GetDocument godoc @Summary Get a document @Description Get a document @Tags documents @Accept json @Produce json @Param id path int true "Document ID" @Success 200 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 404 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/{id} [get]

func ListDocuments

func ListDocuments(w http.ResponseWriter, r *http.Request)

ListDocuments godoc @Summary List all documents @Description List all documents @Tags documents @Accept json @Produce json @Success 200 {object} []Response @Failure 422 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents [get]

func ListDocumentsByFac

func ListDocumentsByFac(w http.ResponseWriter, r *http.Request)

ListDocumentsByFac godoc @Summary List all documents by facility @Description List all documents by facility @Tags documents @Accept json @Produce json @Param Facility path string true "Facility ID" @Success 200 {object} []Response @Failure 400 {object} utils.ErrResponse @Failure 422 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/facility/{Facility} [get]

func ListDocumentsByFacByCat

func ListDocumentsByFacByCat(w http.ResponseWriter, r *http.Request)

ListDocumentsByFacByCat godoc @Summary List all documents by facility and category @Description List all documents by facility and category @Tags documents @Accept json @Produce json @Param Facility path string true "Facility ID" @Param Category path string true "Category" @Success 200 {object} []Response @Failure 400 {object} utils.ErrResponse @Failure 422 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/facility/{Facility}/category/{Category} [get]

func NewDocumentListResponse

func NewDocumentListResponse(d []models.Document) []render.Renderer

func PatchDocument

func PatchDocument(w http.ResponseWriter, r *http.Request)

PatchDocument godoc @Summary Patch a document @Description Patch a document @Tags documents @Accept json @Produce json @Param id path int true "Document ID" @Param document body Request true "Document" @Success 200 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 404 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/{id} [patch]

func Router

func Router(r chi.Router, cfg *config.S3Config)

func UpdateDocument

func UpdateDocument(w http.ResponseWriter, r *http.Request)

UpdateDocument godoc @Summary Update a document @Description Update a document @Tags documents @Accept json @Produce json @Param id path int true "Document ID" @Param document body Request true "Document" @Success 200 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 404 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/{id} [put]

func UploadDocument

func UploadDocument(w http.ResponseWriter, r *http.Request, endpoint string)

UploadDocument godoc @Summary Upload a document @Description Upload a document @Tags documents @Accept json @Produce json @Param id path int true "Document ID" @Param file formData file true "Document file" @Success 204 @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /documents/{id}/upload [post]

Types

type Request

type Request struct {
	Facility    string `json:"facility" example:"ZDV" validate:"required,len=3"`
	Name        string `json:"name" example:"DP001" validate:"required"`
	Description string `json:"description" example:"General Division Policy" validate:"required"`
	Category    string `json:"category" example:"general" validate:"required,oneof=general training information_technology sops loas misc"`
}

func (*Request) Bind

func (req *Request) Bind(r *http.Request) error

func (*Request) Validate

func (req *Request) Validate() error

type Response

type Response struct {
	*models.Document
}

func NewDocumentResponse

func NewDocumentResponse(d *models.Document) *Response

func (*Response) Render

func (res *Response) Render(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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