Skip to content

Commit 9f98a15

Browse files
committed
fix english syntax
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
1 parent 61a63ae commit 9f98a15

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

rest/api.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ func returnJSON(w http.ResponseWriter, content interface{}) {
3737
}
3838

3939
type lspData struct {
40-
// Expr is the promQL expression and is required for all endpoint available.
40+
// Expr is the PromQL expression and is required for all endpoints available.
4141
Expr string `json:"expr"`
42-
// Limit is the number max of result returned to the client. It will be used for the autocompletion and the diagnostics.
42+
// Limit is the maximum number of results returned to the client. It will be used for autocompletion and diagnostics.
4343
Limit *uint64 `json:"limit,omitempty"`
4444
// PositionLine is the number of the line for which the metadata is queried.
4545
PositionLine *float64 `json:"positionLine,omitempty"`
46-
// PositionChar for which the metadata is queried. Characters are counted as UTF16 Codepoints.
46+
// PositionChar for which the metadata is queried. Characters are counted as UTF-16 code points.
4747
PositionChar *float64 `json:"positionChar,omitempty"`
4848
}
4949

@@ -54,7 +54,7 @@ func (d *lspData) UnmarshalJSON(data []byte) error {
5454
return err
5555
}
5656
if len(tmp.Expr) == 0 {
57-
return fmt.Errorf("promQL expression is not specified")
57+
return fmt.Errorf("PromQL expression is not specified")
5858
}
5959
*d = tmp
6060
return nil
@@ -73,22 +73,24 @@ func (d *lspData) returnPosition() (protocol.Position, error) {
7373
}, nil
7474
}
7575

76+
// API is the struct that manages the different endpoint provided by the langServer.
77+
// It also takes care of creating all necessary HTTP middleware.
7678
type API struct {
7779
langServer langserver.HeadlessServer
7880
mdws []middlewareFunc
7981
enableMetrics bool
8082
}
8183

82-
// NewLangServerAPI create a new instance of the Stateless API to use the LangServer through HTTP.
84+
// NewLangServerAPI creates a new instance of the Stateless API to use the LangServer through HTTP.
8385
//
8486
// If metadata is fetched from a remote Prometheus, the metadataService
8587
// implementation from the promql-langserver/prometheus package can be used,
8688
// otherwise you need to provide your own implementation of the interface.
8789
//
8890
// The provided Logger should be synchronized.
8991
//
90-
// In case "enableMetrics" is set to true, endpoint /metrics is then available and a middleware that instrument the different endpoints provided is instantiated.
91-
// Don't use it in case you have already in place such middleware.
92+
// In case "enableMetrics" is set to true, endpoint /metrics is then available and a middleware that instruments the different endpoints provided is instantiated.
93+
// Don't use it in case you already have such middleware in place.
9294
func NewLangServerAPI(ctx context.Context, metadataService promClient.MetadataService, logger log.Logger, enableMetrics bool) (*API, error) {
9395
lgs, err := langserver.CreateHeadlessServer(ctx, metadataService, logger)
9496
if err != nil {

rest/doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ Supported endpoints:
2626
All endpoint are only available through the HTTP method POST. For each request, you have to provide the following JSON:
2727
2828
{
29-
"expr": "a promQL expression" # Mandatory for all available endpoint
30-
"limit": 45 # Optional. It will be used only for the endpoint /diagnostics and /completion. It's the maximum number of result returned.
29+
"expr": "a PromQL expression" # Mandatory for all available endpoints
30+
"limit": 45 # Optional. It will be used only for the endpoints /diagnostics and /completion. It's the maximum number of result returned.
3131
"positionLine": 0 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The line (0 based) for which the metadata is queried.
32-
"positionChar": 2 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The column (0 based) for which the metadata is queried. Characters are counted as UTF16 Codepoints.
32+
"positionChar": 2 # Mandatory for the endpoints /signatureHelp, /hover and /completion. The column (0 based) for which the metadata is queried. Characters are counted as UTF-16 code points.
3333
}
3434
3535

rest/middleware.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func getRequestID(ctx context.Context) (protocol.DocumentURI, error) {
4646
return "", fmt.Errorf("unable to retrieve the requestID")
4747
}
4848

49-
// injectRequestData will create a new context and add to this new one the data passed as parameter.
49+
// injectRequestData will create a new context and add to this new one to the data passed as parameter.
5050
func injectRequestData(ctx context.Context, data *lspData) context.Context {
5151
return context.WithValue(ctx, contextKeyRequestData, data)
5252
}
@@ -81,7 +81,7 @@ type middlewareFunc func(http.HandlerFunc) http.HandlerFunc
8181
func manageDocumentMiddleware(langServer langserver.HeadlessServer) middlewareFunc {
8282
return func(next http.HandlerFunc) http.HandlerFunc {
8383
return func(w http.ResponseWriter, r *http.Request) {
84-
// start to generate an unique ID for the given request
84+
// start to generate a unique ID for the given request
8585
id, err := uuid.NewRandom()
8686
if err != nil {
8787
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -91,7 +91,7 @@ func manageDocumentMiddleware(langServer langserver.HeadlessServer) middlewareFu
9191
// then inject it in the http request context
9292
r = r.WithContext(injectRequestID(r.Context(), requestID))
9393

94-
// then unmarshall the body to the proper struct to be able to retrieve the promQL expr
94+
// then unmarshal the body to the proper struct to be able to retrieve the PromQL expr
9595
data := &lspData{}
9696
if err := json.NewDecoder(r.Body).Decode(data); err != nil {
9797
if err == io.EOF {

0 commit comments

Comments
 (0)