mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-29 09:18:12 -05:00
Compare commits
1 Commits
integratio
...
admin-endp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bc91a6cd8 |
32
internal/server/admin.go
Normal file
32
internal/server/admin.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2025 Google LLC
|
||||||
|
//
|
||||||
|
// 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 server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-chi/chi/v5"
|
||||||
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
|
"github.com/go-chi/render"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRouter creates a router that represents the routes under /admin
|
||||||
|
func adminRouter(s *Server) (chi.Router, error) {
|
||||||
|
r := chi.NewRouter()
|
||||||
|
|
||||||
|
r.Use(middleware.AllowContentType("application/json"))
|
||||||
|
r.Use(middleware.StripSlashes)
|
||||||
|
r.Use(render.SetContentType(render.ContentTypeJSON))
|
||||||
|
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
@@ -337,6 +337,11 @@ func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error) {
|
|||||||
}
|
}
|
||||||
r.Mount("/ui", webR)
|
r.Mount("/ui", webR)
|
||||||
}
|
}
|
||||||
|
adminR, err := adminRouter(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
r.Mount("/admin", adminR)
|
||||||
// default endpoint for validating server is running
|
// default endpoint for validating server is running
|
||||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
_, _ = w.Write([]byte("🧰 Hello, World! 🧰"))
|
_, _ = w.Write([]byte("🧰 Hello, World! 🧰"))
|
||||||
|
|||||||
Reference in New Issue
Block a user