request

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIRequest

func APIRequest(ctx context.Context, request Request)

func MarshalJSON

func MarshalJSON(request Request, secret string) ([]byte, error)

Types

type EncryptedRequest

type EncryptedRequest struct {
	Type          string          `json:"type"`
	EncryptedData json.RawMessage `json:"encrypted_data,omitempty"`
	Encrypted     bool            `json:"encrypted"`
}

type MockRequest

type MockRequest struct {
	mock.Mock
}

MockRequest is an autogenerated mock type for the Request type

func NewMockRequest

func NewMockRequest(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRequest

NewMockRequest creates a new instance of MockRequest. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRequest) RequestData

func (_m *MockRequest) RequestData() json.RawMessage

RequestData provides a mock function with given fields:

func (*MockRequest) RequestType

func (_m *MockRequest) RequestType() RequestType

RequestType provides a mock function with given fields:

func (*MockRequest) ResponseHandler

func (_m *MockRequest) ResponseHandler(_a0 bytes.Buffer)

ResponseHandler provides a mock function with given fields: _a0

type Request

type Request interface {
	RequestType() RequestType
	RequestData() json.RawMessage
	ResponseHandler(bytes.Buffer)
}

type RequestType

type RequestType int
const (
	RequestTypeEncrypted          RequestType = iota + 1 // encrypted
	RequestTypeGetConfig                                 // get_config
	RequestTypeUpdateLocation                            // update_location
	RequestTypeRegisterSensor                            // register_sensor
	RequestTypeUpdateSensorStates                        // update_sensor_states
)

func (RequestType) String

func (i RequestType) String() string

type Response

type Response struct {
	Success bool `json:"success,omitempty"`
}

type UnencryptedRequest

type UnencryptedRequest struct {
	Type string          `json:"type"`
	Data json.RawMessage `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL