Files
2026-09-07 17:12:04 +01:00

59 lines
1.4 KiB
Go

// Code generated by protoc-gen-go-http. DO NOT EDIT.
// source: status.proto
package httppb
import (
"net/http"
"github.com/effective-security/porto/restserver"
"github.com/effective-security/porto/xhttp/correlation"
"github.com/effective-security/porto/xhttp/httperror"
"github.com/effective-security/porto/xhttp/marshal"
"github.com/effective-security/trustyca/api/pb"
"google.golang.org/protobuf/types/known/emptypb"
)
// GetStatusHTTPHandler handles HTTP requests for Status service
func GetStatusHTTPHandler(s pb.StatusServer, withAccessCheck pb.CheckAccessFunc) restserver.Handle {
return func(w http.ResponseWriter, r *http.Request, p restserver.Params) {
action := r.URL.Path
ctx := correlation.WithMetaFromRequest(r)
var err error
var res any
req, _, err := pb.UnmarshalRequest(w, r)
if err != nil {
// UnmarshalRequest already writes error response
return
}
if withAccessCheck != nil {
err = withAccessCheck(ctx, req, action)
if err != nil {
marshal.WriteJSON(w, r, err)
return
}
}
switch action {
case pb.Status_Version_FullMethodName:
res, err = s.Version(ctx, req.(*emptypb.Empty))
case pb.Status_Server_FullMethodName:
res, err = s.Server(ctx, req.(*emptypb.Empty))
default:
err = httperror.Malformed("invalid action: %s", action)
}
if err != nil {
marshal.WriteJSON(w, r, err)
return
}
marshal.WriteJSON(w, r, res)
}
}