better rum todo
This commit is contained in:
1 parent
cb3266bf33
commit
e81b8c2fcd
6 files changed
+231
-51
No files matched your search
+22
-18
@@ -31,14 +31,16 @@ func clipTo(s string, n int) string {
|
||||
}
|
||||
|
||||
type todoPayload struct {
|
||||
Project string `json:"project"`
|
||||
Text string `json:"text"`
|
||||
Component string `json:"component"`
|
||||
Path string `json:"path"`
|
||||
Hash string `json:"hash"`
|
||||
URL string `json:"url"`
|
||||
UserAgent string `json:"ua"`
|
||||
Session string `json:"session"`
|
||||
Project string `json:"project"`
|
||||
Text string `json:"text"`
|
||||
Component string `json:"component"`
|
||||
Path string `json:"path"`
|
||||
Hash string `json:"hash"`
|
||||
URL string `json:"url"`
|
||||
UserAgent string `json:"ua"`
|
||||
Session string `json:"session"`
|
||||
ElementSelector string `json:"elementSelector"`
|
||||
ElementLabel string `json:"elementLabel"`
|
||||
}
|
||||
|
||||
// HandleTodoCreate ingests a todo posted by otel-todo.js. It is guarded by
|
||||
@@ -72,16 +74,18 @@ func (c *Collector) HandleTodoCreate(w http.ResponseWriter, r *http.Request) {
|
||||
id := make([]byte, 8)
|
||||
_, _ = rand.Read(id)
|
||||
t := todos.Todo{
|
||||
ID: hex.EncodeToString(id),
|
||||
Project: project,
|
||||
Text: text,
|
||||
Component: clipTo(p.Component, maxTodoMeta),
|
||||
Path: clipTo(p.Path, maxTodoMeta),
|
||||
Hash: clipTo(p.Hash, maxTodoMeta),
|
||||
URL: clipTo(p.URL, maxTodoMeta),
|
||||
UserAgent: clipTo(p.UserAgent, maxTodoMeta),
|
||||
Session: clipTo(p.Session, maxTodoMeta),
|
||||
CreatedAt: time.Now().UTC(),
|
||||
ID: hex.EncodeToString(id),
|
||||
Project: project,
|
||||
Text: text,
|
||||
Component: clipTo(p.Component, maxTodoMeta),
|
||||
Path: clipTo(p.Path, maxTodoMeta),
|
||||
Hash: clipTo(p.Hash, maxTodoMeta),
|
||||
URL: clipTo(p.URL, maxTodoMeta),
|
||||
UserAgent: clipTo(p.UserAgent, maxTodoMeta),
|
||||
Session: clipTo(p.Session, maxTodoMeta),
|
||||
ElementSelector: clipTo(p.ElementSelector, maxTodoMeta),
|
||||
ElementLabel: clipTo(p.ElementLabel, maxTodoMeta),
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
if err := c.todoStore.Add(r.Context(), t); err != nil {
|
||||
log.Printf("failed to store todo: %v", err)
|
||||
|
||||
Reference in new issue
Block a user