Documentation
¶
Index ¶
- Constants
- Variables
- func NewFileServerWithStatus(name string, code int) http.HandlerFunc
- func ServeFileWithStatus(rw http.ResponseWriter, r *http.Request, name string, code int)
- func WrapHandler(h HandlerFunc, guards ...GuardFn) http.HandlerFunc
- func WriteJSON(w http.ResponseWriter, i interface{})
- type BackendVersionProvider
- type BackendVersionService
- type BuildResponse
- type ErrorResponse
- type GuardFn
- type HTTPError
- type HandlerFunc
- type PlaygroundVersions
- type RunResponse
- type Service
- func (s *Service) HandleArtifactRequest(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleCompile(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleFormatCode(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleGetSnippet(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleGetSuggestion(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleGetVersion(w http.ResponseWriter, _ *http.Request) error
- func (s *Service) HandleGetVersions(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleRunCode(w http.ResponseWriter, r *http.Request) error
- func (s *Service) HandleShare(w http.ResponseWriter, r *http.Request) error
- func (s *Service) Mount(r *mux.Router)
- type ServiceConfig
- type ShareResponse
- type SnippetResponse
- type SpaFileServer
- type SuggestionRequest
- type SuggestionsResponse
- type TemplateArguments
- type TemplateFileServer
- type VersionResponse
- type VersionsInformation
Constants ¶
const ( IndexFileName = "index.html" NotFoundFileName = "404.html" )
const (
VersionCacheTTL = 24 * time.Hour
)
Variables ¶
var ErrSnippetTooLarge = Errorf( http.StatusRequestEntityTooLarge, "code snippet too large (max %d bytes)", goplay.MaxSnippetSize, )
ErrSnippetTooLarge is snippet max size limit error
Functions ¶
func NewFileServerWithStatus ¶
func NewFileServerWithStatus(name string, code int) http.HandlerFunc
NewFileServerWithStatus returns http.Handler which serves specified file with desired HTTP status
func ServeFileWithStatus ¶
ServeFileWithStatus serves file in HTTP response with specified HTTP status.
func WrapHandler ¶
func WrapHandler(h HandlerFunc, guards ...GuardFn) http.HandlerFunc
WrapHandler wraps handler
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, i interface{})
WriteJSON encodes object as JSON and writes it to stdout
Types ¶
type BackendVersionProvider ¶
type BackendVersionProvider interface {
GetVersions(ctx context.Context) (*VersionsInformation, error)
}
type BackendVersionService ¶
type BackendVersionService struct {
// contains filtered or unexported fields
}
BackendVersionService provides information about used Go versions for all backends.
func (*BackendVersionService) GetVersions ¶
func (svc *BackendVersionService) GetVersions(ctx context.Context) (*VersionsInformation, error)
GetVersions provides Go version information for all backends.
type BuildResponse ¶
type BuildResponse struct { // Formatted contains goimport'ed code Formatted string `json:"formatted,omitempty"` // FileName is file name FileName string `json:"fileName,omitempty"` }
BuildResponse is code complile response
type ErrorResponse ¶
type ErrorResponse struct { // Error is error message Error string `json:"error"` // contains filtered or unexported fields }
ErrorResponse is error response
func NewErrorResponse ¶
func NewErrorResponse(err error) *ErrorResponse
NewErrorResponse is ErrorResponse constructor
func (*ErrorResponse) Write ¶
func (r *ErrorResponse) Write(w http.ResponseWriter) http.ResponseWriter
Write writes error to response
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError is HTTP response error
func NewHTTPError ¶
NewHTTPError constructs a new error
func (*HTTPError) WriteResponse ¶
func (err *HTTPError) WriteResponse(rw http.ResponseWriter)
WriteResponse writes error to response
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
HandlerFunc is langserver request handler
type PlaygroundVersions ¶
type PlaygroundVersions struct { // GoCurrent is a current Go version on Go playground. GoCurrent string `json:"current"` // GoPrevious is a previous Go version on Go playground. GoPrevious string `json:"goprev"` // GoTip is a dev branch Go version on Go playground. GoTip string `json:"gotip"` }
PlaygroundVersions contains information about playground Go versions.
func (*PlaygroundVersions) SetBackendVersion ¶
func (vers *PlaygroundVersions) SetBackendVersion(backend goplay.Backend, version string)
type RunResponse ¶
type RunResponse struct { // Formatted contains goimport'ed code Formatted string `json:"formatted,omitempty"` // Events is list of code execution outputs Events []*goplay.CompileEvent `json:"events,omitempty"` }
RunResponse is code run response
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is language server service
func New ¶
func New(cfg ServiceConfig, client *goplay.Client, packages []*analyzer.Package, builder compiler.BuildService) *Service
New is Service constructor
func (*Service) HandleArtifactRequest ¶
HandleArtifactRequest handles WASM build artifact request
func (*Service) HandleCompile ¶
HandleCompile handles WASM build request
func (*Service) HandleFormatCode ¶
HandleFormatCode handles goimports action
func (*Service) HandleGetSnippet ¶
HandleGetSnippet handles snippet load
func (*Service) HandleGetSuggestion ¶
HandleGetSuggestion handles code suggestion
func (*Service) HandleGetVersion ¶
HandleGetVersion handles /api/version
func (*Service) HandleGetVersions ¶
func (*Service) HandleRunCode ¶
HandleRunCode handles code run
func (*Service) HandleShare ¶
HandleShare handles snippet share
type ServiceConfig ¶
type ServiceConfig struct {
Version string
}
type ShareResponse ¶
type ShareResponse struct { string `json:"snippetID"` }SnippetID
ShareResponse is snippet share response
type SnippetResponse ¶
type SnippetResponse struct { // FileName is snippet file name FileName string `json:"fileName"` // Code is snippet source Code string `json:"code"` }
SnippetResponse is snippet response
type SpaFileServer ¶
type SpaFileServer struct { NotFoundHandler http.Handler // contains filtered or unexported fields }
SpaFileServer is a wrapper around http.FileServer for serving SPA contents.
func NewSpaFileServer ¶
func NewSpaFileServer(root string, tplVars TemplateArguments) *SpaFileServer
NewSpaFileServer returns SPA handler
func (*SpaFileServer) ServeHTTP ¶
func (fs *SpaFileServer) ServeHTTP(rw http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler
type SuggestionRequest ¶
type SuggestionRequest struct { PackageName string `json:"packageName"` Value string `json:"value"` }
SuggestionRequest is code completion suggestion request
func (SuggestionRequest) Trim ¶
func (sr SuggestionRequest) Trim() SuggestionRequest
Trim trims request payload
type SuggestionsResponse ¶
type SuggestionsResponse struct { // Suggestions are list of suggestions for monaco Suggestions []*analyzer.CompletionItem `json:"suggestions"` }
SuggestionsResponse is code completion response
func (SuggestionsResponse) Write ¶
func (r SuggestionsResponse) Write(w http.ResponseWriter)
Write writes data to response
type TemplateArguments ¶
type TemplateArguments struct {
GoogleTagID string
}
type TemplateFileServer ¶
type TemplateFileServer struct {
// contains filtered or unexported fields
}
func NewTemplateFileServer ¶
func NewTemplateFileServer(logger *zap.Logger, filePath string, tplVars TemplateArguments) *TemplateFileServer
NewTemplateFileServer returns handler which compiles and serves HTML page template.
func (*TemplateFileServer) ServeHTTP ¶
func (fs *TemplateFileServer) ServeHTTP(rw http.ResponseWriter, r *http.Request)
type VersionResponse ¶
type VersionResponse struct { // Version is server version Version string `json:"version"` }
VersionResponse is version response
func (VersionResponse) Write ¶
func (r VersionResponse) Write(w http.ResponseWriter)
Write writes data to response
type VersionsInformation ¶
type VersionsInformation struct { // Playground contains information about Go versions on Go Playground server. Playground *PlaygroundVersions `json:"playground"` // WebAssembly is host Go version used for building WebAssembly Go files. WebAssembly string `json:"wasm"` }
VersionsInformation contains Go version for different run targets.