chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
lanesapp "inbox/internal/app/lanes"
|
||||
"inbox/internal/base/httpx"
|
||||
"inbox/internal/domain/lane"
|
||||
)
|
||||
|
||||
func (h *Handler) listLanes(w http.ResponseWriter, r *http.Request) {
|
||||
items, err := h.Lanes.ListByTopic(r.Context(), r.PathValue("topicID"))
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, map[string]any{"lanes": items})
|
||||
}
|
||||
|
||||
func (h *Handler) createLane(w http.ResponseWriter, r *http.Request) {
|
||||
type request struct {
|
||||
WorkspaceID string `json:"workspace_id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Status string `json:"status"`
|
||||
BaseBranch string `json:"base_branch"`
|
||||
CreatedByRoleName string `json:"created_by_role_name"`
|
||||
}
|
||||
var req request
|
||||
if err := httpx.DecodeJSON(r, &req); err != nil {
|
||||
httpx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
item, err := h.Lanes.Create(r.Context(), lane.Record{
|
||||
WorkspaceID: req.WorkspaceID,
|
||||
TopicID: r.PathValue("topicID"),
|
||||
Name: req.Name,
|
||||
Slug: req.Slug,
|
||||
Status: lane.Status(req.Status),
|
||||
BaseBranch: req.BaseBranch,
|
||||
CreatedByRoleName: req.CreatedByRoleName,
|
||||
})
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusCreated, item)
|
||||
}
|
||||
|
||||
func (h *Handler) getLane(w http.ResponseWriter, r *http.Request) {
|
||||
item, err := h.Lanes.Get(r.Context(), r.PathValue("laneID"))
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, item)
|
||||
}
|
||||
|
||||
func (h *Handler) patchLane(w http.ResponseWriter, r *http.Request) {
|
||||
type request struct {
|
||||
Name *string `json:"name"`
|
||||
Status *lane.Status `json:"status"`
|
||||
ResultSummaryMarkdown *string `json:"result_summary_markdown"`
|
||||
ErrorMessage *string `json:"error_message"`
|
||||
StartedAt *string `json:"started_at"`
|
||||
CompletedAt *string `json:"completed_at"`
|
||||
}
|
||||
var req request
|
||||
if err := httpx.DecodeJSON(r, &req); err != nil {
|
||||
httpx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
item, err := h.Lanes.Patch(r.Context(), r.PathValue("laneID"), lanesapp.Patch{
|
||||
Name: req.Name,
|
||||
Status: req.Status,
|
||||
ResultSummaryMarkdown: req.ResultSummaryMarkdown,
|
||||
ErrorMessage: req.ErrorMessage,
|
||||
StartedAt: req.StartedAt,
|
||||
CompletedAt: req.CompletedAt,
|
||||
})
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, item)
|
||||
}
|
||||
|
||||
func (h *Handler) startLane(w http.ResponseWriter, r *http.Request) {
|
||||
item, err := h.Lanes.Start(r.Context(), r.PathValue("laneID"))
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusAccepted, item)
|
||||
}
|
||||
|
||||
func (h *Handler) stopLane(w http.ResponseWriter, r *http.Request) {
|
||||
item, err := h.Lanes.Stop(r.Context(), r.PathValue("laneID"))
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusAccepted, item)
|
||||
}
|
||||
Reference in New Issue
Block a user