Documentation
¶
Overview ¶
Package gateway contains the HTTP gateway's marshaling and response helpers.
Index ¶
- func ErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, ...)
- func NewMarshaler() runtime.Marshaler
- func ResponseType(req *http.Request) string
- func RewriteTaskViewResponse(ctx context.Context, response proto.Message) (any, error)
- func WithTaskView(next http.Handler) http.Handler
- type AcceptSpec
- type CustomMarshal
- func (c *CustomMarshal) ContentType(i interface{}) string
- func (c *CustomMarshal) DetectView(task *tes.Task) (tes.View, error)
- func (c *CustomMarshal) Marshal(v interface{}) ([]byte, error)
- func (c *CustomMarshal) MarshalList(list *tes.ListTasksResponse) ([]byte, error)
- func (c *CustomMarshal) MarshalTask(task *tes.Task) ([]byte, error)
- func (c *CustomMarshal) NewDecoder(r io.Reader) runtime.Decoder
- func (c *CustomMarshal) NewEncoder(w io.Writer) runtime.Encoder
- func (c *CustomMarshal) TranslateTask(task *tes.Task, view tes.View) interface{}
- func (c *CustomMarshal) Unmarshal(data []byte, v interface{}) error
- type JSONError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
func ErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, err error)
ErrorHandler maps gRPC errors to HTTP statuses for the gRPC gateway. Returns '400' for invalid backend parameters and '500' for all other errors Required for TES Compliance Tests
func NewMarshaler ¶
func ResponseType ¶
ResponseType determines whether the request should receive HTML or JSON. URL parameters can override the Accept header.
func RewriteTaskViewResponse ¶
Types ¶
type AcceptSpec ¶
AcceptSpec describes an Accept* header.
type CustomMarshal ¶
type CustomMarshal struct {
// contains filtered or unexported fields
}
CustomMarshal is a custom marshaler for the GRPC gateway that returns the required fields based on the View value: - View_MINIMAL: returns only the id and state fields - View_BASIC: returns the id, state, creation_time, description, name, inputs, outputs, resources, tags, volumes, executors, and logs fields - View_FULL: returns all fields
This could be improved by updating the generated protobuf code to include the View field in the Task struct Related discussion: https://github.com/calypr/funnel/pull/716#discussion_r1375155983
func (*CustomMarshal) ContentType ¶
func (c *CustomMarshal) ContentType(i interface{}) string
ContentType return content type of marshaller
func (*CustomMarshal) DetectView ¶
func (*CustomMarshal) Marshal ¶
func (c *CustomMarshal) Marshal(v interface{}) ([]byte, error)
Marshal serializes v into a JSON encoded byte array. If v is of type `proto.Message` the then field "result" is extracted and returned by itself. This is mainly to get around a weird behavior of the GRPC gateway streaming output
func (*CustomMarshal) MarshalList ¶
func (c *CustomMarshal) MarshalList(list *tes.ListTasksResponse) ([]byte, error)
func (*CustomMarshal) MarshalTask ¶
func (c *CustomMarshal) MarshalTask(task *tes.Task) ([]byte, error)
func (*CustomMarshal) NewDecoder ¶
func (c *CustomMarshal) NewDecoder(r io.Reader) runtime.Decoder
NewDecoder shims runtime.Marshaler.NewDecoder
func (*CustomMarshal) NewEncoder ¶
func (c *CustomMarshal) NewEncoder(w io.Writer) runtime.Encoder
NewEncoder shims runtime.Marshaler.NewEncoder
func (*CustomMarshal) TranslateTask ¶
func (c *CustomMarshal) TranslateTask(task *tes.Task, view tes.View) interface{}
func (*CustomMarshal) Unmarshal ¶
func (c *CustomMarshal) Unmarshal(data []byte, v interface{}) error
Unmarshal shims runtime.Marshaler.Unmarshal