handler

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxFilesSnippetSize  int64 = 60 * 1024
	MaxScriptSnippetSize int64 = 1 * 1024 * 1024
)
View Source
var DefaultCorsConfig = CorsConfig{
	AllowOrigins:     []string{"*"},
	AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
	AllowHeaders:     []string{"Authorization", "Origin", "Content-Type", "Content-Length"},
	ExposeHeaders:    []string{"Content-Length", "Authorization", "Content-Type"},
	AllowCredentials: true,
	MaxAge:           300,
}

DefaultCorsConfig is the configuration that will be used in none is provided.

View Source
var JWTAuth *jwtauth.JWTAuth

Functions

func NewServer

func NewServer(config *Config) (*http.Server, error)

Types

type Config

type Config struct {
	BackendURL string
	Port       string

	FileHooksDir                     string
	PluginHookPath                   string
	GracefulRequestCompletionTimeout time.Duration
	ShutdownTimeout                  time.Duration
	ThrottleLimit                    int
	JWTSecretKey                     string
	Dev                              bool
	Cors                             *CorsConfig
}

type CorsConfig added in v1.17.0

type CorsConfig struct {
	AllowOrigins     []string
	AllowCredentials bool
	AllowMethods     []string
	AllowHeaders     []string
	MaxAge           int
	ExposeHeaders    []string
}

type Handler

type Handler struct {
	Config *Config
}

func (*Handler) ActionListHandler added in v1.1.3

func (h *Handler) ActionListHandler(w http.ResponseWriter, _ *http.Request)

func (*Handler) RunFilesHandler

func (h *Handler) RunFilesHandler(w http.ResponseWriter, r *http.Request)

func (*Handler) RunScriptHandler

func (h *Handler) RunScriptHandler(w http.ResponseWriter, r *http.Request)

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder records the standard and error outputs of a sandbox program (comprised of playback headers) and converts it to a sequence of Events. It sanitizes each Event's Message to ensure it is valid UTF-8.

Playground programs precede all their writes with a header (described below) that describes the time the write occurred (in playground time) and the length of the data that will be written. If a non-header is encountered where a header is expected, the output is scanned for the next header and the intervening text string is added to the sequence an event occurring at the same time as the preceding event.

A playback header has this structure:

4 bytes: "\x00\x00PB", a magic header
8 bytes: big-endian int64, unix time in nanoseconds
4 bytes: big-endian int32, length of the next write

func (*Recorder) Events

func (r *Recorder) Events() ([]api.SubmissionResponseEvents, error)

func (*Recorder) Stderr

func (r *Recorder) Stderr() io.Writer

func (*Recorder) Stdout

func (r *Recorder) Stdout() io.Writer

Jump to

Keyboard shortcuts

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