renaming things

master
Jordan Orelli 10 years ago
parent 4a66c02567
commit 0e755398dd

@ -4,11 +4,11 @@ import (
"crypto/rsa"
)
type Auth struct {
type AuthRequest struct {
Nick string
Key *rsa.PublicKey
}
func (a *Auth) Kind() string {
func (a *AuthRequest) Kind() string {
return "auth"
}

@ -152,7 +152,7 @@ func (c *Client) handleListNotes(raw json.RawMessage) error {
}
func (c *Client) handshake() error {
r := &Auth{Nick: c.nick, Key: &c.key.PublicKey}
r := &AuthRequest{Nick: c.nick, Key: &c.key.PublicKey}
c.info("authenticating as %s", c.nick)
promise, err := c.sendRequest(r)
if err != nil {

@ -119,7 +119,7 @@ func getPublic() {
type KeyRequest string
func (k KeyRequest) Kind() string {
return "key"
return "get-key"
}
func (k KeyRequest) Nick() string {

@ -10,7 +10,7 @@ type Message struct {
}
func (m Message) Kind() string {
return "message"
return "send-message"
}
type ListMessages struct {

@ -50,7 +50,7 @@ type ListNotes struct {
}
func (l ListNotes) Kind() string {
return "list-notes"
return "list-notes-request"
}
type ListNotesResponseItem struct {
@ -62,5 +62,5 @@ type ListNotesResponseItem struct {
type ListNotesResponse []ListNotesResponseItem
func (l ListNotesResponse) Kind() string {
return "list-notes"
return "list-notes-response"
}

@ -64,7 +64,7 @@ func decodeRequest(conn net.Conn) (request, error) {
}
switch env.Kind {
case "auth":
var auth Auth
var auth AuthRequest
if err := json.Unmarshal(env.Body, &auth); err != nil {
return nil, fmt.Errorf("unable to unmarshal auth request: %v", err)
}

@ -48,11 +48,11 @@ func (s *serverConnection) handleRequest(request Envelope) error {
return s.handleNoteRequest(request.Id, request.Body)
case "get-note":
return s.handleGetNoteRequest(request.Id, request.Body)
case "list-notes":
case "list-notes-request":
return s.handleListNotesRequest(request.Id, request.Body)
case "key":
case "get-key":
return s.handleKeyRequest(request.Id, request.Body)
case "message":
case "send-message":
return s.handleMessageRequest(request.Id, request.Body)
case "get-message":
return s.handleGetMessageRequest(request.Id, request.Body)
@ -64,7 +64,7 @@ func (s *serverConnection) handleRequest(request Envelope) error {
}
func (s *serverConnection) handleAuthRequest(requestId int, body json.RawMessage) error {
var auth Auth
var auth AuthRequest
if err := json.Unmarshal(body, &auth); err != nil {
return fmt.Errorf("bad auth request: %v", err)
}

Loading…
Cancel
Save