Documentation
¶
Overview ¶
Package demo is a small API for testing DriftGate end to end. Version "v1" is the baseline; "v2" plants drift: a string ID becomes a number, the date format changes, a key appears, a header is added and creating a FAQ entry also writes a log row. Some requests change data, reading a news item among them; one returns personal data, and tokens and cookies are new each time.
The data lives in memory, or in a MySQL/MariaDB database (NewSQL), so the state components of DriftGate can be tested against it.
Index ¶
Constants ¶
const ( ChangeUpload = "upload" // the import reads values as whole numbers ChangeJob = "job" // the queued import job fails ChangeExport = "export" // the export renames a column ChangeLimit = "limit" // the rate limit is 59 per minute instead of 60 )
Planted changes of the upload, queue, export and rate-limit endpoints, switched on with Plant while the server runs.
const AdminToken = "demo-admin-token"
AdminToken is the token the demo accepts for its one identity.
const RateLimit = 60
RateLimit is the number of likes a client may send per minute.
Variables ¶
var Schema = []string{
"CREATE TABLE news (id INT PRIMARY KEY, views INT NOT NULL)",
"INSERT INTO news VALUES (11, 41), (12, 9)",
"CREATE TABLE faq (id INT AUTO_INCREMENT PRIMARY KEY, created_at DATETIME NOT NULL)",
"CREATE TABLE faq_log (id INT AUTO_INCREMENT PRIMARY KEY, faq_id INT NOT NULL)",
}
Schema creates the demo tables with their initial data in a MySQL or MariaDB database.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the demo API.
func (*Server) Plant ¶
Plant switches a planted change (Change*) on or off. Planted changes survive /admin/reset, which restores data only.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the API.
func (*Server) SetVersion ¶
SetVersion switches between "v1" and "v2" while running.