@@ -1643,8 +1643,8 @@ func (cs *ChatServer) Start(staticFS fs.FS) error {
16431643
16441644 if token != "" {
16451645 // Validate token
1646- if strings .HasPrefix (token , "Bearer " ) {
1647- tokenStr := strings . TrimPrefix ( token , "Bearer " )
1646+ if after , ok := strings .CutPrefix (token , "Bearer " ); ok {
1647+ tokenStr := after
16481648 if _ , err := cs .jwtAuth .ValidateToken (tokenStr ); err == nil {
16491649 // User is authenticated, serve original index.html
16501650 cs .HandleIndex (w , r , staticFS )
@@ -1780,12 +1780,12 @@ IMPORTANT:
17801780
17811781 // Clean up the decision
17821782 cleanDecision := strings .TrimSpace (decision )
1783- if strings .HasPrefix (cleanDecision , "```json" ) {
1784- cleanDecision = strings . TrimPrefix ( cleanDecision , "```json" )
1783+ if after , ok := strings .CutPrefix (cleanDecision , "```json" ); ok {
1784+ cleanDecision = after
17851785 cleanDecision = strings .TrimSuffix (cleanDecision , "```" )
17861786 cleanDecision = strings .TrimSpace (cleanDecision )
1787- } else if strings .HasPrefix (cleanDecision , "```" ) {
1788- cleanDecision = strings . TrimPrefix ( cleanDecision , "```" )
1787+ } else if after , ok := strings .CutPrefix (cleanDecision , "```" ); ok {
1788+ cleanDecision = after
17891789 cleanDecision = strings .TrimSuffix (cleanDecision , "```" )
17901790 cleanDecision = strings .TrimSpace (cleanDecision )
17911791 }
@@ -1859,12 +1859,12 @@ IMPORTANT:
18591859
18601860 // Clean up the decision
18611861 cleanDecision := strings .TrimSpace (decision )
1862- if strings .HasPrefix (cleanDecision , "```json" ) {
1863- cleanDecision = strings . TrimPrefix ( cleanDecision , "```json" )
1862+ if after , ok := strings .CutPrefix (cleanDecision , "```json" ); ok {
1863+ cleanDecision = after
18641864 cleanDecision = strings .TrimSuffix (cleanDecision , "```" )
18651865 cleanDecision = strings .TrimSpace (cleanDecision )
1866- } else if strings .HasPrefix (cleanDecision , "```" ) {
1867- cleanDecision = strings . TrimPrefix ( cleanDecision , "```" )
1866+ } else if after , ok := strings .CutPrefix (cleanDecision , "```" ); ok {
1867+ cleanDecision = after
18681868 cleanDecision = strings .TrimSuffix (cleanDecision , "```" )
18691869 cleanDecision = strings .TrimSpace (cleanDecision )
18701870 }
@@ -1916,7 +1916,7 @@ func (s *ChatServer) HandleHealth(w http.ResponseWriter, r *http.Request) {
19161916 w .Header ().Set ("Content-Type" , "application/json" )
19171917 if allHealthy {
19181918 w .WriteHeader (http .StatusOK )
1919- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1919+ if err := json .NewEncoder (w ).Encode (map [string ]any {
19201920 "status" : "healthy" ,
19211921 "timestamp" : time .Now ().UTC (),
19221922 "checks" : results ,
@@ -1925,7 +1925,7 @@ func (s *ChatServer) HandleHealth(w http.ResponseWriter, r *http.Request) {
19251925 }
19261926 } else {
19271927 w .WriteHeader (http .StatusServiceUnavailable )
1928- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1928+ if err := json .NewEncoder (w ).Encode (map [string ]any {
19291929 "status" : "unhealthy" ,
19301930 "timestamp" : time .Now ().UTC (),
19311931 "checks" : results ,
@@ -1937,7 +1937,7 @@ func (s *ChatServer) HandleHealth(w http.ResponseWriter, r *http.Request) {
19371937 // Fallback health check
19381938 w .Header ().Set ("Content-Type" , "application/json" )
19391939 w .WriteHeader (http .StatusOK )
1940- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1940+ if err := json .NewEncoder (w ).Encode (map [string ]any {
19411941 "status" : "healthy" ,
19421942 "timestamp" : time .Now ().UTC (),
19431943 }); err != nil {
@@ -1960,7 +1960,7 @@ func (s *ChatServer) HandleMetrics(w http.ResponseWriter, r *http.Request) {
19601960
19611961 w .Header ().Set ("Content-Type" , "application/json" )
19621962 w .WriteHeader (http .StatusNotFound )
1963- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1963+ if err := json .NewEncoder (w ).Encode (map [string ]any {
19641964 "error" : "Metrics collection not enabled" ,
19651965 }); err != nil {
19661966 log .Printf ("Warning: Failed to encode metrics error response: %v" , err )
@@ -1988,15 +1988,15 @@ func (s *ChatServer) HandleReady(w http.ResponseWriter, r *http.Request) {
19881988 w .Header ().Set ("Content-Type" , "application/json" )
19891989 if ready {
19901990 w .WriteHeader (http .StatusOK )
1991- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1991+ if err := json .NewEncoder (w ).Encode (map [string ]any {
19921992 "status" : "ready" ,
19931993 "timestamp" : time .Now ().UTC (),
19941994 }); err != nil {
19951995 log .Printf ("Warning: Failed to encode ready response: %v" , err )
19961996 }
19971997 } else {
19981998 w .WriteHeader (http .StatusServiceUnavailable )
1999- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
1999+ if err := json .NewEncoder (w ).Encode (map [string ]any {
20002000 "status" : "not ready" ,
20012001 "timestamp" : time .Now ().UTC (),
20022002 }); err != nil {
@@ -2007,7 +2007,7 @@ func (s *ChatServer) HandleReady(w http.ResponseWriter, r *http.Request) {
20072007 // Default to ready if no health checker is configured
20082008 w .Header ().Set ("Content-Type" , "application/json" )
20092009 w .WriteHeader (http .StatusOK )
2010- if err := json .NewEncoder (w ).Encode (map [string ]interface {} {
2010+ if err := json .NewEncoder (w ).Encode (map [string ]any {
20112011 "status" : "ready" ,
20122012 "timestamp" : time .Now ().UTC (),
20132013 }); err != nil {
@@ -2018,12 +2018,12 @@ func (s *ChatServer) HandleReady(w http.ResponseWriter, r *http.Request) {
20182018
20192019// HandleInfo handles server info requests
20202020func (s * ChatServer ) HandleInfo (w http.ResponseWriter , r * http.Request ) {
2021- info := map [string ]interface {} {
2021+ info := map [string ]any {
20222022 "service" : "LangChat Agent" ,
20232023 "version" : "1.0.0" ,
20242024 "environment" : "development" , // TODO: Get from config manager
20252025 "timestamp" : time .Now ().UTC (),
2026- "features" : map [string ]interface {} {
2026+ "features" : map [string ]any {
20272027 "agent_management" : s .lifecycleManager != nil ,
20282028 "monitoring" : s .metricsCollector != nil ,
20292029 "health_checks" : s .healthChecker != nil ,
@@ -2039,16 +2039,16 @@ func (s *ChatServer) HandleInfo(w http.ResponseWriter, r *http.Request) {
20392039 }
20402040
20412041 // Add configuration summary
2042- info ["config" ] = map [string ]interface {} {
2043- "server" : map [string ]interface {} {
2042+ info ["config" ] = map [string ]any {
2043+ "server" : map [string ]any {
20442044 "host" : s .config .Server .Host ,
20452045 "port" : s .config .Server .Port ,
20462046 },
2047- "agent" : map [string ]interface {} {
2047+ "agent" : map [string ]any {
20482048 "max_concurrent" : s .config .Agent .MaxConcurrent ,
20492049 "max_idle_time" : s .config .Agent .MaxIdleTime ,
20502050 },
2051- "monitoring" : map [string ]interface {} {
2051+ "monitoring" : map [string ]any {
20522052 "enabled" : s .config .Monitoring .Enabled ,
20532053 "metrics_port" : s .config .Monitoring .MetricsPort ,
20542054 },
0 commit comments