Skip to content

Commit

Permalink
basic ack
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Jun 5, 2018
1 parent 8cdc839 commit 76fe8f5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ACK

HTTP service acknowledgement structure.
24 changes: 24 additions & 0 deletions ack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package service

// Ack
type Ack struct {
Version int `json:"ack_version"`
Uuid string `json:"ack_uuid"`
RequestUuid string `json:"req_uuid"`
DateTime string `json:"date_time"`
Success bool `json:"success"`
ServerCode int `json:"server_code"`
Location string `json:"location"`
PayloadType string `json:"payload_type"`
Payload interface{} `json:"payload"`
}

// SetPayload
func (a *Ack) SetPayload(payload interface{}) {
a.Payload = payload
}

// SetPayloadType
func (a *Ack) SetPayloadType(payloadType string) {
a.PayloadType = payloadType
}
29 changes: 29 additions & 0 deletions ginack/ack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ginack

import (
"github.com/gin-gonic/gin"
"github.com/satori/go.uuid"
"github.com/txn2/service"

"time"
)

func Ack(c *gin.Context) service.Ack {
t := time.Now()
u, _ := uuid.NewV4()

// get uuid from header
ru := c.Request.Header.Get("uuid")

ack := service.Ack{
Uuid: u.String(),
RequestUuid: ru,
ServerCode: 200,
Success: true,
Version: 5,
DateTime: t.Format(time.RFC3339),
Location: c.Request.URL.String(),
}

return ack
}

0 comments on commit 76fe8f5

Please sign in to comment.