Remove printing from client register code
This commit is contained in:
parent
75732476be
commit
b1e4a0cf72
2 changed files with 8 additions and 9 deletions
|
@ -3,7 +3,6 @@ package client
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -11,7 +10,7 @@ import (
|
|||
"crispbyte.dev/sig-auth/server"
|
||||
)
|
||||
|
||||
func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
||||
func RegisterKey(baseUrl *url.URL, key string, userId string) (string, error) {
|
||||
request := server.RegisterRequest{
|
||||
UserId: userId,
|
||||
Key: key,
|
||||
|
@ -27,7 +26,7 @@ func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
|||
bytes.NewBuffer(json_data))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
@ -35,12 +34,10 @@ func RegisterKey(baseUrl *url.URL, key string, userId string) error {
|
|||
out, err := io.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
|
||||
fmt.Println(resp.StatusCode)
|
||||
fmt.Println(resp.Header)
|
||||
fmt.Println(string(out[:]))
|
||||
keyId := string(out[:])
|
||||
|
||||
return nil
|
||||
return keyId, nil
|
||||
}
|
||||
|
|
4
main.go
4
main.go
|
@ -108,11 +108,13 @@ func registerKey(baseUrl *url.URL, keyFile string, userId string) {
|
|||
|
||||
keyText := string(keyBytes)
|
||||
|
||||
err = client.RegisterKey(baseUrl, keyText, userId)
|
||||
keyId, err := client.RegisterKey(baseUrl, keyText, userId)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Registered key id: %s\n", keyId)
|
||||
}
|
||||
|
||||
func runServer(simulateCaddy bool, useTempDb bool, dbPath string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue