fix(CurrentRecipePointer): 🐛 Fix cache recipe
Remove continue last opened version
This commit is contained in:
parent
4219c1cb43
commit
2b8745679f
16 changed files with 481 additions and 174 deletions
49
server/data/socket-client.go
Normal file
49
server/data/socket-client.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// type SocketCli struct {
|
||||
// Client *socketio.Client
|
||||
// }
|
||||
|
||||
func NewSocketCli(user, response_room string) *map[string]interface{} {
|
||||
|
||||
ticketUrl := "http://localhost:3001"
|
||||
|
||||
ticketForm := map[string]string{
|
||||
"user": user,
|
||||
"response_room": response_room,
|
||||
}
|
||||
|
||||
ticketByte, _ := json.Marshal(ticketForm)
|
||||
|
||||
req, err := http.NewRequest("POST", ticketUrl, bytes.NewBuffer(ticketByte))
|
||||
if err != nil {
|
||||
fmt.Println("create request fail: ", err)
|
||||
}
|
||||
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
client := &http.Client{}
|
||||
result, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Println("request fail: ", err)
|
||||
}
|
||||
defer result.Body.Close()
|
||||
|
||||
bill := &map[string]interface{}{}
|
||||
decodeErr := json.NewDecoder(result.Body).Decode(bill)
|
||||
if decodeErr != nil {
|
||||
fmt.Println("decode request error: ", decodeErr)
|
||||
}
|
||||
|
||||
if result.StatusCode != http.StatusCreated {
|
||||
fmt.Println("not expected status: ", result.Status)
|
||||
}
|
||||
|
||||
return bill
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue