mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Convert everything but serverkeyapi to inthttp (#1096)
* Convert roomserver to new inthttp format * Convert eduserver to new inthttp format * Convert appservice to new inthttp format
This commit is contained in:
parent
d785ad82b9
commit
9834ac97db
29 changed files with 879 additions and 1013 deletions
|
@ -19,12 +19,8 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
internalHTTP "github.com/matrix-org/dendrite/internal/http"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
)
|
||||
|
||||
// InputTypingEvent is an event for notifying the typing server about typing updates.
|
||||
|
@ -77,48 +73,3 @@ type EDUServerInputAPI interface {
|
|||
response *InputSendToDeviceEventResponse,
|
||||
) error
|
||||
}
|
||||
|
||||
// EDUServerInputTypingEventPath is the HTTP path for the InputTypingEvent API.
|
||||
const EDUServerInputTypingEventPath = "/eduserver/input"
|
||||
|
||||
// EDUServerInputSendToDeviceEventPath is the HTTP path for the InputSendToDeviceEvent API.
|
||||
const EDUServerInputSendToDeviceEventPath = "/eduserver/sendToDevice"
|
||||
|
||||
// NewEDUServerInputAPIHTTP creates a EDUServerInputAPI implemented by talking to a HTTP POST API.
|
||||
func NewEDUServerInputAPIHTTP(eduServerURL string, httpClient *http.Client) (EDUServerInputAPI, error) {
|
||||
if httpClient == nil {
|
||||
return nil, errors.New("NewTypingServerInputAPIHTTP: httpClient is <nil>")
|
||||
}
|
||||
return &httpEDUServerInputAPI{eduServerURL, httpClient}, nil
|
||||
}
|
||||
|
||||
type httpEDUServerInputAPI struct {
|
||||
eduServerURL string
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// InputTypingEvent implements EDUServerInputAPI
|
||||
func (h *httpEDUServerInputAPI) InputTypingEvent(
|
||||
ctx context.Context,
|
||||
request *InputTypingEventRequest,
|
||||
response *InputTypingEventResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "InputTypingEvent")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.eduServerURL + EDUServerInputTypingEventPath
|
||||
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// InputSendToDeviceEvent implements EDUServerInputAPI
|
||||
func (h *httpEDUServerInputAPI) InputSendToDeviceEvent(
|
||||
ctx context.Context,
|
||||
request *InputSendToDeviceEventRequest,
|
||||
response *InputSendToDeviceEventResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "InputSendToDeviceEvent")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.eduServerURL + EDUServerInputSendToDeviceEventPath
|
||||
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue