gateway

package
v0.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package gateway contains the HTTP gateway's marshaling and response helpers.

Index

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 NewMarshaler() runtime.Marshaler

func ResponseType

func ResponseType(req *http.Request) string

ResponseType determines whether the request should receive HTML or JSON. URL parameters can override the Accept header.

func RewriteTaskViewResponse

func RewriteTaskViewResponse(ctx context.Context, response proto.Message) (any, error)

func WithTaskView

func WithTaskView(next http.Handler) http.Handler

Types

type AcceptSpec

type AcceptSpec struct {
	Value string
	Q     float64
}

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 (c *CustomMarshal) DetectView(task *tes.Task) (tes.View, error)

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

type JSONError

type JSONError struct {
	Error string `json:"error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL