Spaces:
Runtime error
Runtime error
Download controllers/option_controller.go from lifedebugger/quzuu-api-dev-v2: direct link, hf CLI and curl.
- Browser
- Download file 935 Bytes
-
https://huggingface.co/spaces/lifedebugger/quzuu-api-dev-v2/resolve/main/controllers/option_controller.go
- Command line
-
hf download hf://spaces/lifedebugger/quzuu-api-dev-v2/controllers/option_controller.go
-
curl -L -o option_controller.go https://huggingface.co/spaces/lifedebugger/quzuu-api-dev-v2/resolve/main/controllers/option_controller.go
935 Bytes
| package controllers | |
| import ( | |
| "abdanhafidz.com/go-boilerplate/models/dto" | |
| "abdanhafidz.com/go-boilerplate/services" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| type OptionController interface { | |
| CreateBulk(ctx *gin.Context) | |
| GetBySlug(ctx *gin.Context) | |
| } | |
| type optionController struct { | |
| optionService services.OptionService | |
| } | |
| func NewOptionController(optionService services.OptionService) OptionController { | |
| return &optionController{optionService: optionService} | |
| } | |
| func (c *optionController) CreateBulk(ctx *gin.Context) { | |
| var payload []dto.OptionsRequest | |
| payload = RequestJSON[[]dto.OptionsRequest](ctx) | |
| err := c.optionService.CreateBulk(ctx.Request.Context(), payload) | |
| ResponseJSON[any](ctx, payload, gin.H{"status": "ok"}, err) | |
| } | |
| func (c *optionController) GetBySlug(ctx *gin.Context) { | |
| slug := ctx.Param("slug") | |
| res, err := c.optionService.GetBySlug(ctx.Request.Context(), slug) | |
| ResponseJSON(ctx, gin.H{"slug": slug}, res, err) | |
| } | |