Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在构建一个 API,如果它们中的大多数是这样的,我无法弄清楚如何返回一个空响应:
func GetEntityInstance(c *fiber.Ctx) error { ... return c.Status(fiber.StatusCreated).JSON(fiber.Map{ "id_created": new_id, }) }
如何发送空正文响应?
就这么简单:
func main() { app := fiber.New() app.Get("/", func(c *fiber.Ctx) error { return c.Send(nil) }) app.Listen(":5000") }
你也可以这样做return c.SendStatus(http.StatusAccepted)
return c.SendStatus(http.StatusAccepted)