[PD2] Code almost all done. Need to add logout and change help message
Co-authored-by: tsousa111 <tiagao2001@hotmail.com>
This commit is contained in:
parent
e2c3d75223
commit
6f8219d991
12 changed files with 123 additions and 212 deletions
|
@ -26,8 +26,8 @@ func forwardStoreUserCert(tlsConfig *tls.Config,uid string,storeUserCertificate
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error parsing URL: %v", err)
|
||||
}
|
||||
parsedURL.JoinPath("certs")
|
||||
parsedURL.JoinPath(uid)
|
||||
parsedURL = parsedURL.JoinPath("certs")
|
||||
parsedURL = parsedURL.JoinPath(uid)
|
||||
|
||||
jsonData, err := json.Marshal(storeUserCertificate)
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func forwardStoreUserCert(tlsConfig *tls.Config,uid string,storeUserCertificate
|
|||
return resp.StatusCode,body,nil
|
||||
}
|
||||
|
||||
func forwardGetMessage(tlsConfig *tls.Config,uid string,getMsg protocol.GetMsg) (int,[]byte,error) {
|
||||
func forwardGetMessage(tlsConfig *tls.Config,uid string,num string) (int,[]byte,error) {
|
||||
client := getHTTPClient(tlsConfig)
|
||||
|
||||
// Parse the base URL
|
||||
|
@ -62,9 +62,9 @@ func forwardGetMessage(tlsConfig *tls.Config,uid string,getMsg protocol.GetMsg)
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error parsing URL: %v", err)
|
||||
}
|
||||
parsedURL.JoinPath("message")
|
||||
parsedURL.JoinPath(uid)
|
||||
parsedURL.JoinPath(fmt.Sprint(getMsg.Num))
|
||||
parsedURL = parsedURL.JoinPath("message")
|
||||
parsedURL = parsedURL.JoinPath(uid)
|
||||
parsedURL = parsedURL.JoinPath(num)
|
||||
|
||||
|
||||
req, err := http.NewRequest("GET", parsedURL.String(), nil)
|
||||
|
@ -87,7 +87,7 @@ func forwardGetMessage(tlsConfig *tls.Config,uid string,getMsg protocol.GetMsg)
|
|||
return resp.StatusCode,body,nil
|
||||
}
|
||||
|
||||
func forwardGetUnreadMsgsInfo(tlsConfig *tls.Config,uid string,getUnreadMsgsInfo protocol.GetUnreadMsgsInfo) (int,[]byte,error) {
|
||||
func forwardGetUnreadMsgsInfo(tlsConfig *tls.Config,uid string,page string,pagesize string) (int,[]byte,error) {
|
||||
client := getHTTPClient(tlsConfig)
|
||||
|
||||
// Parse the base URL
|
||||
|
@ -95,12 +95,12 @@ func forwardGetUnreadMsgsInfo(tlsConfig *tls.Config,uid string,getUnreadMsgsInfo
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error parsing URL: %v", err)
|
||||
}
|
||||
parsedURL.JoinPath("queue")
|
||||
parsedURL.JoinPath(uid)
|
||||
parsedURL = parsedURL.JoinPath("queue")
|
||||
parsedURL = parsedURL.JoinPath(uid)
|
||||
|
||||
query := parsedURL.Query()
|
||||
query.Set("page", fmt.Sprint(getUnreadMsgsInfo.Page))
|
||||
query.Set("pagesize", fmt.Sprint(getUnreadMsgsInfo.PageSize))
|
||||
query.Set("page", page)
|
||||
query.Set("pagesize", pagesize)
|
||||
parsedURL.RawQuery = query.Encode()
|
||||
|
||||
req, err := http.NewRequest("GET", parsedURL.String(), nil)
|
||||
|
@ -119,11 +119,11 @@ func forwardGetUnreadMsgsInfo(tlsConfig *tls.Config,uid string,getUnreadMsgsInfo
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error reading response body: %v", err)
|
||||
}
|
||||
|
||||
|
||||
return resp.StatusCode,body,nil
|
||||
}
|
||||
|
||||
func forwardGetUserCert(tlsConfig *tls.Config,getUserCert protocol.GetUserCert) (int,[]byte,error) {
|
||||
func forwardGetUserCert(tlsConfig *tls.Config,uid string) (int,[]byte,error) {
|
||||
client := getHTTPClient(tlsConfig)
|
||||
|
||||
// Parse the base URL
|
||||
|
@ -131,8 +131,8 @@ func forwardGetUserCert(tlsConfig *tls.Config,getUserCert protocol.GetUserCert)
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error parsing URL: %v", err)
|
||||
}
|
||||
parsedURL.JoinPath("cert")
|
||||
parsedURL.JoinPath(getUserCert.UID)
|
||||
parsedURL = parsedURL.JoinPath("cert")
|
||||
parsedURL = parsedURL.JoinPath(uid)
|
||||
|
||||
req, err := http.NewRequest("GET", parsedURL.String(), nil)
|
||||
if err != nil {
|
||||
|
@ -162,8 +162,8 @@ func forwardSendMessage(tlsConfig *tls.Config,uid string,sendMsg protocol.SendMs
|
|||
if err != nil {
|
||||
return 0,nil,fmt.Errorf("error parsing URL: %v", err)
|
||||
}
|
||||
parsedURL.JoinPath("message")
|
||||
parsedURL.JoinPath(uid)
|
||||
parsedURL = parsedURL.JoinPath("message")
|
||||
parsedURL = parsedURL.JoinPath(uid)
|
||||
|
||||
jsonData, err := json.Marshal(sendMsg)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue