| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package localhostv1connect |
| 6 |
|
| 7 |
import ( |
| 8 |
connect "connectrpc.com/connect" |
| 9 |
context "context" |
| 10 |
errors "errors" |
| 11 |
v1 "github.com/humanlogio/api/go/svc/localhost/v1" |
| 12 |
http "net/http" |
| 13 |
strings "strings" |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
const _ = connect.IsAtLeastVersion1_13_0 |
| 22 |
|
| 23 |
const ( |
| 24 |
|
| 25 |
LocalhostServiceName = "svc.localhost.v1.LocalhostService" |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const ( |
| 36 |
|
| 37 |
LocalhostServicePingProcedure = "/svc.localhost.v1.LocalhostService/Ping" |
| 38 |
|
| 39 |
|
| 40 |
LocalhostServiceDoLoginProcedure = "/svc.localhost.v1.LocalhostService/DoLogin" |
| 41 |
|
| 42 |
|
| 43 |
LocalhostServiceDoLogoutProcedure = "/svc.localhost.v1.LocalhostService/DoLogout" |
| 44 |
|
| 45 |
|
| 46 |
LocalhostServiceDoUpdateProcedure = "/svc.localhost.v1.LocalhostService/DoUpdate" |
| 47 |
|
| 48 |
|
| 49 |
LocalhostServiceDoRestartProcedure = "/svc.localhost.v1.LocalhostService/DoRestart" |
| 50 |
|
| 51 |
|
| 52 |
LocalhostServiceGetConfigProcedure = "/svc.localhost.v1.LocalhostService/GetConfig" |
| 53 |
|
| 54 |
|
| 55 |
LocalhostServiceSetConfigProcedure = "/svc.localhost.v1.LocalhostService/SetConfig" |
| 56 |
) |
| 57 |
|
| 58 |
|
| 59 |
type LocalhostServiceClient interface { |
| 60 |
Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) |
| 61 |
DoLogin(context.Context, *connect.Request[v1.DoLoginRequest]) (*connect.Response[v1.DoLoginResponse], error) |
| 62 |
DoLogout(context.Context, *connect.Request[v1.DoLogoutRequest]) (*connect.Response[v1.DoLogoutResponse], error) |
| 63 |
DoUpdate(context.Context, *connect.Request[v1.DoUpdateRequest]) (*connect.Response[v1.DoUpdateResponse], error) |
| 64 |
DoRestart(context.Context, *connect.Request[v1.DoRestartRequest]) (*connect.Response[v1.DoRestartResponse], error) |
| 65 |
GetConfig(context.Context, *connect.Request[v1.GetConfigRequest]) (*connect.Response[v1.GetConfigResponse], error) |
| 66 |
SetConfig(context.Context, *connect.Request[v1.SetConfigRequest]) (*connect.Response[v1.SetConfigResponse], error) |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
func NewLocalhostServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) LocalhostServiceClient { |
| 77 |
baseURL = strings.TrimRight(baseURL, "/") |
| 78 |
localhostServiceMethods := v1.File_svc_localhost_v1_service_proto.Services().ByName("LocalhostService").Methods() |
| 79 |
return &localhostServiceClient{ |
| 80 |
ping: connect.NewClient[v1.PingRequest, v1.PingResponse]( |
| 81 |
httpClient, |
| 82 |
baseURL+LocalhostServicePingProcedure, |
| 83 |
connect.WithSchema(localhostServiceMethods.ByName("Ping")), |
| 84 |
connect.WithClientOptions(opts...), |
| 85 |
), |
| 86 |
doLogin: connect.NewClient[v1.DoLoginRequest, v1.DoLoginResponse]( |
| 87 |
httpClient, |
| 88 |
baseURL+LocalhostServiceDoLoginProcedure, |
| 89 |
connect.WithSchema(localhostServiceMethods.ByName("DoLogin")), |
| 90 |
connect.WithClientOptions(opts...), |
| 91 |
), |
| 92 |
doLogout: connect.NewClient[v1.DoLogoutRequest, v1.DoLogoutResponse]( |
| 93 |
httpClient, |
| 94 |
baseURL+LocalhostServiceDoLogoutProcedure, |
| 95 |
connect.WithSchema(localhostServiceMethods.ByName("DoLogout")), |
| 96 |
connect.WithClientOptions(opts...), |
| 97 |
), |
| 98 |
doUpdate: connect.NewClient[v1.DoUpdateRequest, v1.DoUpdateResponse]( |
| 99 |
httpClient, |
| 100 |
baseURL+LocalhostServiceDoUpdateProcedure, |
| 101 |
connect.WithSchema(localhostServiceMethods.ByName("DoUpdate")), |
| 102 |
connect.WithClientOptions(opts...), |
| 103 |
), |
| 104 |
doRestart: connect.NewClient[v1.DoRestartRequest, v1.DoRestartResponse]( |
| 105 |
httpClient, |
| 106 |
baseURL+LocalhostServiceDoRestartProcedure, |
| 107 |
connect.WithSchema(localhostServiceMethods.ByName("DoRestart")), |
| 108 |
connect.WithClientOptions(opts...), |
| 109 |
), |
| 110 |
getConfig: connect.NewClient[v1.GetConfigRequest, v1.GetConfigResponse]( |
| 111 |
httpClient, |
| 112 |
baseURL+LocalhostServiceGetConfigProcedure, |
| 113 |
connect.WithSchema(localhostServiceMethods.ByName("GetConfig")), |
| 114 |
connect.WithClientOptions(opts...), |
| 115 |
), |
| 116 |
setConfig: connect.NewClient[v1.SetConfigRequest, v1.SetConfigResponse]( |
| 117 |
httpClient, |
| 118 |
baseURL+LocalhostServiceSetConfigProcedure, |
| 119 |
connect.WithSchema(localhostServiceMethods.ByName("SetConfig")), |
| 120 |
connect.WithClientOptions(opts...), |
| 121 |
), |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
type localhostServiceClient struct { |
| 127 |
ping *connect.Client[v1.PingRequest, v1.PingResponse] |
| 128 |
doLogin *connect.Client[v1.DoLoginRequest, v1.DoLoginResponse] |
| 129 |
doLogout *connect.Client[v1.DoLogoutRequest, v1.DoLogoutResponse] |
| 130 |
doUpdate *connect.Client[v1.DoUpdateRequest, v1.DoUpdateResponse] |
| 131 |
doRestart *connect.Client[v1.DoRestartRequest, v1.DoRestartResponse] |
| 132 |
getConfig *connect.Client[v1.GetConfigRequest, v1.GetConfigResponse] |
| 133 |
setConfig *connect.Client[v1.SetConfigRequest, v1.SetConfigResponse] |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
func (c *localhostServiceClient) Ping(ctx context.Context, req *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) { |
| 138 |
return c.ping.CallUnary(ctx, req) |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
func (c *localhostServiceClient) DoLogin(ctx context.Context, req *connect.Request[v1.DoLoginRequest]) (*connect.Response[v1.DoLoginResponse], error) { |
| 143 |
return c.doLogin.CallUnary(ctx, req) |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
func (c *localhostServiceClient) DoLogout(ctx context.Context, req *connect.Request[v1.DoLogoutRequest]) (*connect.Response[v1.DoLogoutResponse], error) { |
| 148 |
return c.doLogout.CallUnary(ctx, req) |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
func (c *localhostServiceClient) DoUpdate(ctx context.Context, req *connect.Request[v1.DoUpdateRequest]) (*connect.Response[v1.DoUpdateResponse], error) { |
| 153 |
return c.doUpdate.CallUnary(ctx, req) |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
func (c *localhostServiceClient) DoRestart(ctx context.Context, req *connect.Request[v1.DoRestartRequest]) (*connect.Response[v1.DoRestartResponse], error) { |
| 158 |
return c.doRestart.CallUnary(ctx, req) |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
func (c *localhostServiceClient) GetConfig(ctx context.Context, req *connect.Request[v1.GetConfigRequest]) (*connect.Response[v1.GetConfigResponse], error) { |
| 163 |
return c.getConfig.CallUnary(ctx, req) |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
func (c *localhostServiceClient) SetConfig(ctx context.Context, req *connect.Request[v1.SetConfigRequest]) (*connect.Response[v1.SetConfigResponse], error) { |
| 168 |
return c.setConfig.CallUnary(ctx, req) |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
type LocalhostServiceHandler interface { |
| 173 |
Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) |
| 174 |
DoLogin(context.Context, *connect.Request[v1.DoLoginRequest]) (*connect.Response[v1.DoLoginResponse], error) |
| 175 |
DoLogout(context.Context, *connect.Request[v1.DoLogoutRequest]) (*connect.Response[v1.DoLogoutResponse], error) |
| 176 |
DoUpdate(context.Context, *connect.Request[v1.DoUpdateRequest]) (*connect.Response[v1.DoUpdateResponse], error) |
| 177 |
DoRestart(context.Context, *connect.Request[v1.DoRestartRequest]) (*connect.Response[v1.DoRestartResponse], error) |
| 178 |
GetConfig(context.Context, *connect.Request[v1.GetConfigRequest]) (*connect.Response[v1.GetConfigResponse], error) |
| 179 |
SetConfig(context.Context, *connect.Request[v1.SetConfigRequest]) (*connect.Response[v1.SetConfigResponse], error) |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
func NewLocalhostServiceHandler(svc LocalhostServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { |
| 188 |
localhostServiceMethods := v1.File_svc_localhost_v1_service_proto.Services().ByName("LocalhostService").Methods() |
| 189 |
localhostServicePingHandler := connect.NewUnaryHandler( |
| 190 |
LocalhostServicePingProcedure, |
| 191 |
svc.Ping, |
| 192 |
connect.WithSchema(localhostServiceMethods.ByName("Ping")), |
| 193 |
connect.WithHandlerOptions(opts...), |
| 194 |
) |
| 195 |
localhostServiceDoLoginHandler := connect.NewUnaryHandler( |
| 196 |
LocalhostServiceDoLoginProcedure, |
| 197 |
svc.DoLogin, |
| 198 |
connect.WithSchema(localhostServiceMethods.ByName("DoLogin")), |
| 199 |
connect.WithHandlerOptions(opts...), |
| 200 |
) |
| 201 |
localhostServiceDoLogoutHandler := connect.NewUnaryHandler( |
| 202 |
LocalhostServiceDoLogoutProcedure, |
| 203 |
svc.DoLogout, |
| 204 |
connect.WithSchema(localhostServiceMethods.ByName("DoLogout")), |
| 205 |
connect.WithHandlerOptions(opts...), |
| 206 |
) |
| 207 |
localhostServiceDoUpdateHandler := connect.NewUnaryHandler( |
| 208 |
LocalhostServiceDoUpdateProcedure, |
| 209 |
svc.DoUpdate, |
| 210 |
connect.WithSchema(localhostServiceMethods.ByName("DoUpdate")), |
| 211 |
connect.WithHandlerOptions(opts...), |
| 212 |
) |
| 213 |
localhostServiceDoRestartHandler := connect.NewUnaryHandler( |
| 214 |
LocalhostServiceDoRestartProcedure, |
| 215 |
svc.DoRestart, |
| 216 |
connect.WithSchema(localhostServiceMethods.ByName("DoRestart")), |
| 217 |
connect.WithHandlerOptions(opts...), |
| 218 |
) |
| 219 |
localhostServiceGetConfigHandler := connect.NewUnaryHandler( |
| 220 |
LocalhostServiceGetConfigProcedure, |
| 221 |
svc.GetConfig, |
| 222 |
connect.WithSchema(localhostServiceMethods.ByName("GetConfig")), |
| 223 |
connect.WithHandlerOptions(opts...), |
| 224 |
) |
| 225 |
localhostServiceSetConfigHandler := connect.NewUnaryHandler( |
| 226 |
LocalhostServiceSetConfigProcedure, |
| 227 |
svc.SetConfig, |
| 228 |
connect.WithSchema(localhostServiceMethods.ByName("SetConfig")), |
| 229 |
connect.WithHandlerOptions(opts...), |
| 230 |
) |
| 231 |
return "/svc.localhost.v1.LocalhostService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 232 |
switch r.URL.Path { |
| 233 |
case LocalhostServicePingProcedure: |
| 234 |
localhostServicePingHandler.ServeHTTP(w, r) |
| 235 |
case LocalhostServiceDoLoginProcedure: |
| 236 |
localhostServiceDoLoginHandler.ServeHTTP(w, r) |
| 237 |
case LocalhostServiceDoLogoutProcedure: |
| 238 |
localhostServiceDoLogoutHandler.ServeHTTP(w, r) |
| 239 |
case LocalhostServiceDoUpdateProcedure: |
| 240 |
localhostServiceDoUpdateHandler.ServeHTTP(w, r) |
| 241 |
case LocalhostServiceDoRestartProcedure: |
| 242 |
localhostServiceDoRestartHandler.ServeHTTP(w, r) |
| 243 |
case LocalhostServiceGetConfigProcedure: |
| 244 |
localhostServiceGetConfigHandler.ServeHTTP(w, r) |
| 245 |
case LocalhostServiceSetConfigProcedure: |
| 246 |
localhostServiceSetConfigHandler.ServeHTTP(w, r) |
| 247 |
default: |
| 248 |
http.NotFound(w, r) |
| 249 |
} |
| 250 |
}) |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
type UnimplementedLocalhostServiceHandler struct{} |
| 255 |
|
| 256 |
func (UnimplementedLocalhostServiceHandler) Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) { |
| 257 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.Ping is not implemented")) |
| 258 |
} |
| 259 |
|
| 260 |
func (UnimplementedLocalhostServiceHandler) DoLogin(context.Context, *connect.Request[v1.DoLoginRequest]) (*connect.Response[v1.DoLoginResponse], error) { |
| 261 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.DoLogin is not implemented")) |
| 262 |
} |
| 263 |
|
| 264 |
func (UnimplementedLocalhostServiceHandler) DoLogout(context.Context, *connect.Request[v1.DoLogoutRequest]) (*connect.Response[v1.DoLogoutResponse], error) { |
| 265 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.DoLogout is not implemented")) |
| 266 |
} |
| 267 |
|
| 268 |
func (UnimplementedLocalhostServiceHandler) DoUpdate(context.Context, *connect.Request[v1.DoUpdateRequest]) (*connect.Response[v1.DoUpdateResponse], error) { |
| 269 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.DoUpdate is not implemented")) |
| 270 |
} |
| 271 |
|
| 272 |
func (UnimplementedLocalhostServiceHandler) DoRestart(context.Context, *connect.Request[v1.DoRestartRequest]) (*connect.Response[v1.DoRestartResponse], error) { |
| 273 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.DoRestart is not implemented")) |
| 274 |
} |
| 275 |
|
| 276 |
func (UnimplementedLocalhostServiceHandler) GetConfig(context.Context, *connect.Request[v1.GetConfigRequest]) (*connect.Response[v1.GetConfigResponse], error) { |
| 277 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.GetConfig is not implemented")) |
| 278 |
} |
| 279 |
|
| 280 |
func (UnimplementedLocalhostServiceHandler) SetConfig(context.Context, *connect.Request[v1.SetConfigRequest]) (*connect.Response[v1.SetConfigResponse], error) { |
| 281 |
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("svc.localhost.v1.LocalhostService.SetConfig is not implemented")) |
| 282 |
} |