31 lines
795 B
Go
31 lines
795 B
Go
package service
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.ostiwe.com/ostiwe-com/status/modules/log"
|
|
http2 "git.ostiwe.com/ostiwe-com/status/pkg/http"
|
|
"git.ostiwe.com/ostiwe-com/status/repository"
|
|
"git.ostiwe.com/ostiwe-com/status/transform"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func processGetServicesHandler(c *gin.Context, publicOnly bool, serviceRepository repository.Service) {
|
|
items, err := serviceRepository.All(c.Request.Context(), -1, 0, publicOnly)
|
|
if err != nil {
|
|
log.Global.Get(log.SERVER).Error(err)
|
|
|
|
writeErr := http2.NewResponseErrBuilder().
|
|
WithMessage("Fetch service error").
|
|
WithStatusCode(http.StatusInternalServerError).
|
|
Send(c)
|
|
if writeErr != nil {
|
|
log.Global.Get(log.SERVER).Error(writeErr)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, transform.PublicServices(items...))
|
|
}
|