-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.idea | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ACK | ||
|
||
HTTP service acknowledgement structure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |