Documentation ¶
Index ¶
- Constants
- Variables
- func NewRouter(transactions *service.TransactionService, oidcHandler *oidc.Handler, ...) http.Handler
- func NewServer(handler http.Handler) *http.Server
- type ApiError
- type AssetController
- type AssetMetadataDto
- type CreateRecipeResponse
- type DeleteRecipeRequest
- type DownloadAssetRequest
- type ReadRecipeRequest
- type RecipeController
- func (c *RecipeController) Create(ctx echo.Context) error
- func (c *RecipeController) Delete(ctx echo.Context) error
- func (c *RecipeController) List(ctx echo.Context) error
- func (c *RecipeController) ListImages(ctx echo.Context) error
- func (c *RecipeController) Read(ctx echo.Context) error
- func (c *RecipeController) Update(ctx echo.Context) error
- func (c *RecipeController) UploadImage(ctx echo.Context) error
- type RecipeMetadataDto
- type SessionController
- type UpdateRecipeRequest
- type UploadRecipeImageRequest
- type UserInfoResponse
Constants ¶
const (
MediaTypeMarkdown = "text/markdown"
)
Variables ¶
var ( ErrInternal = ApiError{ Status: http.StatusInternalServerError, Code: "internal", } Status: http.StatusUnauthorized, Code: "unauthorized", } ErrResourceNotFound = ApiError{ Status: http.StatusNotFound, Code: "resource.notfound", } ErrContraintViolation = ApiError{ Status: http.StatusConflict, Code: "validation.constraint.violation", } ErrRecipeInvalid = ApiError{ Status: http.StatusUnprocessableEntity, Code: "validation.recipe.invalid", } ErrMultipartUnexpectedPart = ApiError{ Status: http.StatusUnprocessableEntity, Code: "validation.multipart.unexpectedpart", } )
Functions ¶
func NewRouter ¶
func NewRouter( transactions *service.TransactionService, oidcHandler *oidc.Handler, oidcSession *oidc.Session, sessions *SessionController, assets *AssetController, recipes *RecipeController, ) http.Handler
Types ¶
type ApiError ¶
type ApiError struct { Status int `json:"status"` Code string `json:"code"` Internal error `json:"-"` } // @name ApiError
func (ApiError) WithInternal ¶
type AssetController ¶
type AssetController struct {
// contains filtered or unexported fields
}
func NewAssetController ¶
func NewAssetController(assets *service.AssetService) *AssetController
func (*AssetController) Download ¶
func (c *AssetController) Download(ctx echo.Context) error
@summary Download an asset @id downloadAsset @tags assets @router /assets/{assetId} [get] @produce application/octet-stream @param assetId path string true "Asset ID" @param thumbnail query string false "Thumbnail version of an image" @success 200 {blob} blob @failure 400 {object} ApiError @failure 404 {object} ApiError
type AssetMetadataDto ¶
type CreateRecipeResponse ¶
type DeleteRecipeRequest ¶
type DownloadAssetRequest ¶
type DownloadAssetRequest struct { ID xid.ID `param:"assetId"` Thumbnail service.ThumbnailSize `query:"thumbnail"` }
type ReadRecipeRequest ¶
type RecipeController ¶
type RecipeController struct {
// contains filtered or unexported fields
}
func NewRecipeController ¶
func NewRecipeController(recipes *service.RecipeService) *RecipeController
func (*RecipeController) Create ¶
func (c *RecipeController) Create(ctx echo.Context) error
@summary Create a new recipe @id createRecipe @tags recipes @router /recipes [post] @accept text/markdown @produce application/json @param content body string true "Recipe content" @success 201 {object} CreateRecipeResponse @failure 400 {object} ApiError @failure 422 {object} ApiError
func (*RecipeController) Delete ¶
func (c *RecipeController) Delete(ctx echo.Context) error
@summary Delete a recipe @id deleteRecipe @tags recipes @router /recipes/{recipeId} [delete] @param recipeId path string true "Recipe ID" @success 204 @failure 400 {object} ApiError @failure 404 {object} ApiError
func (*RecipeController) List ¶
func (c *RecipeController) List(ctx echo.Context) error
@summary List recipes @id listRecipes @tags recipes @router /recipes [get] @produce application/json @success 200 {array} RecipeMetadataDto
func (*RecipeController) ListImages ¶
func (c *RecipeController) ListImages(ctx echo.Context) error
@summary List recipe images @id listRecipeImages @tags recipes assets @router /recipes/{recipeId}/images [get] @param recipeId path string true "Recipe ID" @produce application/json @success 200 {array} AssetMetadataDto
func (*RecipeController) Read ¶
func (c *RecipeController) Read(ctx echo.Context) error
@summary Read a recipe @id readRecipe @tags recipes @router /recipes/{recipeId} [get] @produce text/markdown @param recipeId path string true "Recipe ID" @success 200 {string} string @failure 400 {object} ApiError @failure 404 {object} ApiError
func (*RecipeController) Update ¶
func (c *RecipeController) Update(ctx echo.Context) error
@summary Update a recipe @id updateRecipe @tags recipes @router /recipes/{recipeId} [put] @accept text/markdown @param recipeId path string true "Recipe ID" @param content body string true "Recipe content" @success 204 @failure 400 {object} ApiError @failure 404 {object} ApiError @failure 409 {object} ApiError @failure 422 {object} ApiError
func (*RecipeController) UploadImage ¶
func (c *RecipeController) UploadImage(ctx echo.Context) error
@summary Upload a new recipe image @id uploadRecipeImage @tags recipes assets @router /recipes/{recipeId}/images [post] @accept multipart/form-data @produce application/json @param recipeId path string true "Recipe ID" @param image formData file true "Image" @success 201 {object} AssetMetadataDto @failure 400 {object} ApiError @failure 404 {object} ApiError @failure 422 {object} ApiError
type RecipeMetadataDto ¶
type SessionController ¶
type SessionController struct {
// contains filtered or unexported fields
}
func NewSessionController ¶
func NewSessionController(session *oidc.Session) *SessionController
func (*SessionController) UserInfo ¶
func (c *SessionController) UserInfo(ctx echo.Context) error
@summary Get user info @id userInfo @tags session @router /session/info [get] @produce application/json @success 200 {object} UserInfoResponse @success 401 {object} ApiError