2016-09-05 20:03:58 +00:00
|
|
|
package server
|
2016-09-05 19:50:57 +00:00
|
|
|
|
|
|
|
import (
|
2016-09-08 01:24:11 +00:00
|
|
|
"encoding/json"
|
2016-09-05 19:50:57 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
func decodeGetInfoAboutSessionRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return getInfoAboutSessionRequest{ID: id}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetInfoAboutSessionsForUserRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return getInfoAboutSessionsForUserRequest{ID: id}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeDeleteSessionRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return deleteSessionRequest{ID: id}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeDeleteSessionsForUserRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return deleteSessionsForUserRequest{ID: id}, nil
|
|
|
|
}
|
2016-09-08 01:24:11 +00:00
|
|
|
|
|
|
|
func decodeLoginRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
var req loginRequest
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}
|