langserver

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexFileName    = "index.html"
	NotFoundFileName = "404.html"
)

Variables

This section is empty.

Functions

func NewCORSDisablerWrapper

func NewCORSDisablerWrapper(parent http.Handler) http.Handler

NewCORSDisablerWrapper returns new CORS middleware

func NewFileServerWithStatus added in v1.7.1

func NewFileServerWithStatus(name string, code int) http.HandlerFunc

NewFileServerWithStatus returns http.Handler which serves specified file with desired HTTP status

func ServeFileWithStatus added in v1.7.1

func ServeFileWithStatus(rw http.ResponseWriter, r *http.Request, name string, code int)

ServeFileWithStatus serves file in HTTP response with specified HTTP status.

func ValidateContentLength added in v1.4.1

func ValidateContentLength(r *http.Request) error

ValidateContentLength validates Go code snippet size

func WrapHandler added in v1.4.1

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 BuildResponse added in v1.3.0

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

Write writes error to response

type GuardFn added in v1.4.1

type GuardFn func(r *http.Request) error

GuardFn is guard middleware handler

type HTTPError added in v1.4.1

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

HTTPError is HTTP response error

func Errorf

func Errorf(code int, format string, args ...interface{}) *HTTPError

Errorf returns new formatted error

func NewHTTPError added in v1.4.1

func NewHTTPError(code int, err error) *HTTPError

NewHTTPError constructs a new error

func (*HTTPError) Error added in v1.4.1

func (err *HTTPError) Error() string

Error implements error

func (*HTTPError) Unwrap added in v1.4.1

func (err *HTTPError) Unwrap() error

Unwrap implements error

func (*HTTPError) WriteResponse added in v1.4.1

func (err *HTTPError) WriteResponse(rw http.ResponseWriter)

WriteResponse writes error to response

type HandlerFunc added in v1.4.1

type HandlerFunc func(http.ResponseWriter, *http.Request) error

HandlerFunc is langserver request handler

type IndexFileServer added in v1.7.1

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

func NewIndexFileServer added in v1.7.1

func NewIndexFileServer(root string) *IndexFileServer

NewIndexFileServer returns handler which serves index.html page from root.

func (IndexFileServer) ServeHTTP added in v1.7.1

func (fs IndexFileServer) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type PlaygroundServices added in v1.8.0

type PlaygroundServices struct {
	Default *goplay.Client
	GoTip   *goplay.Client
}

type RunResponse added in v1.3.0

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(version string, playgrounds *PlaygroundServices, packages []*analyzer.Package, builder compiler.BuildService) *Service

New is Service constructor

func (*Service) HandleArtifactRequest added in v1.3.0

func (s *Service) HandleArtifactRequest(w http.ResponseWriter, r *http.Request) error

HandleArtifactRequest handles WASM build artifact request

func (*Service) HandleCompile added in v1.3.0

func (s *Service) HandleCompile(w http.ResponseWriter, r *http.Request) error

HandleCompile handles WASM build request

func (*Service) HandleFormatCode added in v1.3.0

func (s *Service) HandleFormatCode(w http.ResponseWriter, r *http.Request) error

HandleFormatCode handles goimports action

func (*Service) HandleGetSnippet added in v1.3.0

func (s *Service) HandleGetSnippet(w http.ResponseWriter, r *http.Request) error

HandleGetSnippet handles snippet load

func (*Service) HandleGetSuggestion added in v1.3.0

func (s *Service) HandleGetSuggestion(w http.ResponseWriter, r *http.Request) error

HandleGetSuggestion handles code suggestion

func (*Service) HandleGetVersion added in v1.5.0

func (s *Service) HandleGetVersion(w http.ResponseWriter, _ *http.Request) error

HandleGetVersion handles /api/version

func (*Service) HandleRunCode added in v1.3.0

func (s *Service) HandleRunCode(w http.ResponseWriter, r *http.Request) error

HandleRunCode handles code run

func (*Service) HandleShare added in v1.3.0

func (s *Service) HandleShare(w http.ResponseWriter, r *http.Request) error

HandleShare handles snippet share

func (*Service) Mount

func (s *Service) Mount(r *mux.Router)

Mount mounts service on route

type ShareResponse added in v1.1.0

type ShareResponse struct {
	// SnippetID is definitely not a snippet id (sarcasm)
	SnippetID string `json:"snippetID"`
}

ShareResponse is snippet share response

type SnippetResponse added in v1.1.0

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 added in v1.1.0

type SpaFileServer struct {
	NotFoundHandler http.Handler
	// contains filtered or unexported fields
}

SpaFileServer is a wrapper around http.FileServer for serving SPA contents.

func NewSpaFileServer added in v1.7.1

func NewSpaFileServer(root string) *SpaFileServer

NewSpaFileServer returns SPA handler

func (*SpaFileServer) ServeHTTP added in v1.7.1

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

Trim trims request payload

type SuggestionsResponse

type SuggestionsResponse struct {
	// Suggestions is list of suggestions for monaco
	Suggestions []*analyzer.CompletionItem `json:"suggestions"`
}

SuggestionsResponse is code completion response

func (SuggestionsResponse) Write

Write writes data to response

type VersionResponse added in v1.5.0

type VersionResponse struct {
	// Version is server version
	Version string `json:"version"`
}

VersionResponse is version response

func (VersionResponse) Write added in v1.5.0

func (r VersionResponse) Write(w http.ResponseWriter)

Write writes data to response

Jump to

Keyboard shortcuts

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