Documentation
¶
Index ¶
- Variables
- func AddUser(w http.ResponseWriter, r *http.Request)
- func GenerateToken() string
- func GetUser(w http.ResponseWriter, r *http.Request)
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(hmc chan HandlerMessage) *mux.Router
- func PutBase(w http.ResponseWriter, r *http.Request)
- func PutElbow(w http.ResponseWriter, r *http.Request)
- func PutGripper(w http.ResponseWriter, r *http.Request)
- func PutPosture(w http.ResponseWriter, r *http.Request)
- func PutReset(w http.ResponseWriter, r *http.Request)
- func PutShoulder(w http.ResponseWriter, r *http.Request)
- func PutWristAngle(w http.ResponseWriter, r *http.Request)
- func PutWristRotation(w http.ResponseWriter, r *http.Request)
- func RemoveUser(w http.ResponseWriter, r *http.Request)
- type HandlerMessage
- type HandlerMessageType
- type PostureCommand
- type RobotCommand
- type Route
- type Routes
- type Token
- type User
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
var APIBaseURL = "/leubot"
APIBaseURL is the path to the API
var APIHost = "api.interactions.ics.unisg.ch"
APIHost is the hostname
var APIProto = "https://"
APIProto for API access protocol
var HandlerChannel chan HandlerMessage
HandlerChannel is used to communicate between the router and other application logic
Functions ¶
func NewRouter ¶
func NewRouter(hmc chan HandlerMessage) *mux.Router
NewRouter creats a new instance of Router
func PutBase ¶
func PutBase(w http.ResponseWriter, r *http.Request)
PutBase processes the request for Base
func PutElbow ¶
func PutElbow(w http.ResponseWriter, r *http.Request)
PutElbow processes the request for Elbow
func PutGripper ¶
func PutGripper(w http.ResponseWriter, r *http.Request)
PutGripper processes the request for Gripper
func PutPosture ¶ added in v1.1.1
func PutPosture(w http.ResponseWriter, r *http.Request)
PutPosture sets all the joints at once
func PutReset ¶
func PutReset(w http.ResponseWriter, r *http.Request)
PutReset processes the request to reset
func PutShoulder ¶
func PutShoulder(w http.ResponseWriter, r *http.Request)
PutShoulder processes the request for Shoulder
func PutWristAngle ¶
func PutWristAngle(w http.ResponseWriter, r *http.Request)
PutWristAngle processes the request for WristAngle
func PutWristRotation ¶
func PutWristRotation(w http.ResponseWriter, r *http.Request)
PutWristRotation processes the request for WristRotation
func RemoveUser ¶
func RemoveUser(w http.ResponseWriter, r *http.Request)
Types ¶
type HandlerMessage ¶
type HandlerMessage struct {
Type HandlerMessageType
Value []interface{}
}
HandlerMessage contains the payload for the command messages
type HandlerMessageType ¶
type HandlerMessageType int
HandlerMessageType is the type for HandlerMessage
const ( // TypeAddUser is to add a user TypeAddUser HandlerMessageType = iota // TypeUserAdded says the user is added TypeUserAdded // TypeUserExisted says a user already exists TypeUserExisted // TypeInvalidUserInfo says something wrong about the user to be added TypeInvalidUserInfo // TypeDeleteUser is to delete a user TypeDeleteUser // TypeUserDeleted says the user is deleted TypeUserDeleted // TypeUserNotFound says no such user exists TypeUserNotFound // TypeGetUser is to get the current user TypeGetUser // TypeCurrentUser has the current user info TypeCurrentUser // TypePutBase is to change Base TypePutBase // TypePutShoulder is to change Shoulder TypePutShoulder // TypePutElbow is to change Elbow TypePutElbow // TypePutWristAngle is to change WristAngle TypePutWristAngle // TypePutWristRotation is to change WristRotation TypePutWristRotation // TypePutGripper is to change Gripper TypePutGripper // TypePutPosture is to set a posture TypePutPosture // TypePutReset is to reset Leubot TypePutReset // TypeActionPerformed says the action was performed TypeActionPerformed // TypeInvalidToken says something is wrong with Token TypeInvalidToken // TypeInvalidCommand says no such command TypeInvalidCommand // TypeSomethingWentWrong says it didn't go well TypeSomethingWentWrong )
type PostureCommand ¶ added in v1.1.1
type PostureCommand struct {
Token string `json:"token"`
Base uint16 `json:"base"`
Shoulder uint16 `json:"shoulder"`
Elbow uint16 `json:"elbow"`
WristAngle uint16 `json:"wristAngle"`
WristRotation uint16 `json:"wristRotation"`
Gripper uint16 `json:"gripper"`
Delta uint8 `json:"delta"`
}
PostureCommand is a struct for a posture
type RobotCommand ¶
RobotCommand is a struct for each command
type Route ¶
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
Route is a basic pattern of the rounting