Documentation ¶
Index ¶
- Constants
- func NewRouter(w io.Writer, s SessionStore, db *sql.DB) http.Handler
- type AuthenticateRequest
- type AuthenticateResponse
- type ChangeUserPasswordRequest
- type CreateDeviceRequest
- type CreateUserRequest
- type ErrorResponse
- type MemorySessionStore
- type NoteRequest
- type QueryDeviceResponse
- type QueryModelResponse
- type ReadLocationsResponse
- type ReadStatusesResponse
- type Session
- type SessionStore
Constants ¶
const TransactionKey contextKey = 0
TransactionKey is the context key for the database transaction for a request
const UserKey contextKey = 1
UserKey is the context key for the user for a request
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthenticateRequest ¶
AuthenticateRequest is an email/password authentication request
type AuthenticateResponse ¶
type AuthenticateResponse struct { SessionKey string `json:"session_key"` User *api.User `json:"user"` }
AuthenticateResponse is a successful authentication response including the session key and User
type ChangeUserPasswordRequest ¶
type ChangeUserPasswordRequest struct { OldPassword string `json:"old_password"` NewPassword string `json:"new_password"` }
ChangeUserPasswordRequest is a request to change a User's password
type CreateDeviceRequest ¶
CreateDeviceRequest is a Device Create and Note Create request combined
type CreateUserRequest ¶
type CreateUserRequest struct { Email string `json:"email"` Password string `json:"password"` Name string `json:"name"` }
CreateUserRequest is a request to create a new User
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Error string `json:"error"` DuplicateID int64 `json:"duplicate_id,omitempty"` }
ErrorResponse represents an HTTP error. If the error is 409 Conflict, the DuplicateID field will be populated.
type MemorySessionStore ¶
type MemorySessionStore struct {
// contains filtered or unexported fields
}
MemorySessionStore represents a SessionStore that uses an in-memory map
func NewMemorySessionStore ¶
func NewMemorySessionStore(duration time.Duration) *MemorySessionStore
NewMemorySessionStore returns a new MemorySessionStore with the given expiration duration.
type NoteRequest ¶
type NoteRequest struct {
Note string `json:"note"`
}
NoteRequest is a note encapsulated in a JSON object
type QueryDeviceResponse ¶
QueryDeviceResponse contains a list of Models
type QueryModelResponse ¶
QueryModelResponse contains a list of Models
type ReadLocationsResponse ¶
ReadLocationsResponse contains a list of allowed Locations
type ReadStatusesResponse ¶
ReadStatusesResponse contains a list of allowed Statuses
type SessionStore ¶
type SessionStore interface { //Create returns a new sessionID with the given User id. If the backend malfunctions, //sessionID will be an empty string and err will be non-nil. Create(userID int64) (sessionID string, err error) //Check returns whether or not sessionID is a valid session. //If sessionID is not valid, session will be nil. //If the backend malfunctions, session will be nil and err will be non-nil. Check(sessionID string) (session *Session, err error) }
SessionStore is an interface to an arbitrary session backend.