MCPcopy Index your code
hub / github.com/coder/coder / getChatWorkspaceTTL

Method getChatWorkspaceTTL

coderd/exp_chats.go:5393–5420  ·  view source on GitHub ↗

EXPERIMENTAL: this endpoint is experimental and is subject to change. nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

5391//
5392//nolint:revive // get-return: revive assumes get* must be a getter, but this is an HTTP handler.
5393func (api *API) getChatWorkspaceTTL(rw http.ResponseWriter, r *http.Request) {
5394 ctx := r.Context()
5395 raw, err := api.Database.GetChatWorkspaceTTL(ctx)
5396 if err != nil {
5397 if httpapi.Is404Error(err) {
5398 httpapi.ResourceNotFound(rw)
5399 return
5400 }
5401 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5402 Message: "Internal error fetching workspace TTL setting.",
5403 Detail: err.Error(),
5404 })
5405 return
5406 }
5407 // Validate/default the stored value so callers always receive a
5408 // well-formed duration string.
5409 d, err := codersdk.ParseChatWorkspaceTTL(raw)
5410 if err != nil {
5411 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
5412 Message: "Stored workspace TTL is invalid.",
5413 Detail: err.Error(),
5414 })
5415 return
5416 }
5417 httpapi.Write(ctx, rw, http.StatusOK, codersdk.ChatWorkspaceTTLResponse{
5418 WorkspaceTTLMillis: d.Milliseconds(),
5419 })
5420}
5421
5422// EXPERIMENTAL: this endpoint is experimental and is subject to change.
5423func (api *API) putChatWorkspaceTTL(rw http.ResponseWriter, r *http.Request) {

Callers 1

chatWorkspaceTTLFunction · 0.80

Calls 7

Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
ParseChatWorkspaceTTLFunction · 0.92
ContextMethod · 0.65
GetChatWorkspaceTTLMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected