mirror of
https://github.com/hanzoai/ai.git
synced 2026-11-20 14:13:23 +00:00
Both used to read a render map the handler filled before the framework serialised it. There is no such map now, so both read the response itself: the status code says how it went, and the body is the bytes the client received. That is one fewer rendering of the same answer, and it cannot disagree with what was sent. DenyRequest, responseError, the routing-ledger export and the zen relay take the context or the stream writer. Metrics go out through the adaptor, which is what a plain http.Handler needs. A second repair from the same bulk pass: `c.Ctx.Input.RequestBody = chatBody` had become `c.Body() = chatBody`, an assignment to a call. The Responses bridge sets the request body it forwards, so it is a write — SetBody — not a read. 909 compile errors down to 24.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
// Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
|
|
// Portions Copyright 2025 The OpenAgent Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package controllers
|
|
|
|
import (
|
|
"github.com/hanzoai/ai/object"
|
|
"github.com/zap-proto/fiber/v3/middleware/adaptor"
|
|
)
|
|
|
|
// GetPrometheusInfo
|
|
// @Title GetPrometheusInfo
|
|
// @Tag System API
|
|
// @Description get Prometheus Info
|
|
// @Success 200 {object} object.PrometheusInfo The Response object
|
|
// @router /get-prometheus-info [get]
|
|
func (c *ApiController) GetPrometheusInfo() {
|
|
if !c.RequireAdmin() {
|
|
return
|
|
}
|
|
|
|
prometheusInfo, err := object.GetPrometheusInfo()
|
|
if err != nil {
|
|
c.ResponseError(err.Error())
|
|
return
|
|
}
|
|
|
|
c.ResponseOk(prometheusInfo)
|
|
}
|
|
|
|
// GetMetrics
|
|
// @Title GetMetrics
|
|
// @Tag System API
|
|
// @Description get Prometheus metrics
|
|
// @Success 200 {string} string The Response metrics in Prometheus format
|
|
// @router /metrics [get]
|
|
func (c *ApiController) GetMetrics() {
|
|
if !c.RequireAdmin() {
|
|
return
|
|
}
|
|
|
|
_ = adaptor.HTTPHandler(object.MetricsHandler())(c.Fiber())
|
|
}
|