2019-10-07 08:14:47 -06:00
|
|
|
// Copyright (c) Mainflux
|
2018-08-26 13:15:48 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-05-10 23:53:25 +02:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/mainflux/mainflux"
|
|
|
|
)
|
|
|
|
|
2019-09-28 11:15:41 +00:00
|
|
|
var (
|
|
|
|
_ mainflux.Response = (*tokenRes)(nil)
|
|
|
|
_ mainflux.Response = (*identityRes)(nil)
|
|
|
|
)
|
2018-05-10 23:53:25 +02:00
|
|
|
|
|
|
|
type tokenRes struct {
|
|
|
|
Token string `json:"token,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res tokenRes) Code() int {
|
|
|
|
return http.StatusCreated
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res tokenRes) Headers() map[string]string {
|
|
|
|
return map[string]string{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res tokenRes) Empty() bool {
|
|
|
|
return res.Token == ""
|
|
|
|
}
|
2019-09-28 11:15:41 +00:00
|
|
|
|
|
|
|
type identityRes struct {
|
|
|
|
Email string `json:"email"`
|
|
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res identityRes) Code() int {
|
|
|
|
return http.StatusOK
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res identityRes) Headers() map[string]string {
|
|
|
|
return map[string]string{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res identityRes) Empty() bool {
|
|
|
|
return false
|
|
|
|
}
|