server

package
v0.0.0-...-8736fb8 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2017 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissParam = errors.New("miss param")
	ErrBadType   = errors.New("code type invalid")
)

Functions

func GetCodeHandle

func GetCodeHandle(w http.ResponseWriter, req *http.Request)

func SaveCode

func SaveCode(ctx context.Context, code string, t LangType) (string, error)

生成一个新的 ID,将用户代码存入数据库并返回 ID

func SaveCodeHandle

func SaveCodeHandle(w http.ResponseWriter, req *http.Request)

func Start

func Start(client *client.Client)

Types

type CodeGetter

type CodeGetter func(*http.Request) (string, error)

CodeGetter 从 request 中获取用户上传的代码

type Handle

type Handle func(http.ResponseWriter, *http.Request)

func WrapMiddleware

func WrapMiddleware(middleware []Middleware, handle Handle) Handle

WrapMiddleware 将给定的中间件包裹在 handle 上。Slice 中最后一个中间件 最先处理 HTTP 请求

func WrapParseMultipartForm

func WrapParseMultipartForm(handle Handle) Handle

type LangType

type LangType uint8
const (
	TypeGo LangType = iota
	TypePy
	TypeC
	TypePy2
	TypeErr
)

func GetCode

func GetCode(ctx context.Context, url string) (code string, t LangType, err error)

根据用户的分享 ID 获取保存的代码和代码语言类型

func ItoLangType

func ItoLangType(t string) (lt LangType, err error)

func (LangType) String

func (t LangType) String() string

type Middleware

type Middleware func(Handle) Handle

type TempFileContainerFactory

type TempFileContainerFactory struct {
	Client *client.Client
	Getter CodeGetter
	Writer dockerserver.ResultWriter
}

func (TempFileContainerFactory) NewHandleFunc

func (factory TempFileContainerFactory) NewHandleFunc(creator func(*os.File) dockerserver.ContainerCreator) Handle

Jump to

Keyboard shortcuts

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