mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-02 22:17:10 +08:00

* Update copyright comment for go files Signed-off-by: nwneisen <nwneisen@gmail.com> * Update copyright in assortment of file types Signed-off-by: nwneisen <nwneisen@gmail.com> * Remove missed copyright date Signed-off-by: nwneisen <nwneisen@gmail.com>
51 lines
834 B
Go
51 lines
834 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package http
|
|
|
|
import "github.com/mainflux/mainflux/things"
|
|
|
|
var _ apiReq = (*identifyReq)(nil)
|
|
|
|
type apiReq interface {
|
|
validate() error
|
|
}
|
|
|
|
type identifyReq struct {
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
func (req identifyReq) validate() error {
|
|
if req.Token == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type canAccessReq struct {
|
|
chanID string
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
func (req canAccessReq) validate() error {
|
|
if req.Token == "" || req.chanID == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type canAccessByIDReq struct {
|
|
chanID string
|
|
ThingID string `json:"thing_id"`
|
|
}
|
|
|
|
func (req canAccessByIDReq) validate() error {
|
|
if req.ThingID == "" || req.chanID == "" {
|
|
return things.ErrUnauthorizedAccess
|
|
}
|
|
|
|
return nil
|
|
}
|