✨ Adds selecting client by name
This commit is contained in:
parent
473ea2ba74
commit
50420bc0a5
@ -159,7 +159,7 @@ func main() {
|
|||||||
|
|
||||||
app.GET("/admin/clients/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
app.GET("/admin/clients/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
if client.ID == id {
|
if client.ID == id || client.Name == id.String() {
|
||||||
return c.JSONPretty(http.StatusOK, client, indent)
|
return c.JSONPretty(http.StatusOK, client, indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ func main() {
|
|||||||
return c.NoContent(http.StatusInternalServerError)
|
return c.NoContent(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSONPretty(http.StatusOK, string(bytes[:n]), indent)
|
return c.String(http.StatusOK, string(bytes[:n]))
|
||||||
})))
|
})))
|
||||||
|
|
||||||
app.POST("/admin/name/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
app.POST("/admin/name/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
||||||
@ -238,7 +238,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
if client.ID == id {
|
if client.ID == id || client.Name == id.String() {
|
||||||
client.Name = name
|
client.Name = name
|
||||||
client.UpdatedAt = time.Now()
|
client.UpdatedAt = time.Now()
|
||||||
return c.JSON(http.StatusOK, echo.Map{"message": "ok"})
|
return c.JSON(http.StatusOK, echo.Map{"message": "ok"})
|
||||||
@ -250,7 +250,7 @@ func main() {
|
|||||||
|
|
||||||
app.POST("/admin/exit/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
app.POST("/admin/exit/:id", authed(idparam(func(c echo.Context, id uuid.UUID) error {
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
if client.ID == id {
|
if client.ID == id || client.Name == id.String() {
|
||||||
client.ExitWanted = true
|
client.ExitWanted = true
|
||||||
return c.JSON(http.StatusOK, echo.Map{"message": "ok"})
|
return c.JSON(http.StatusOK, echo.Map{"message": "ok"})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user