Internal API for Appservices (#541)
This commit is contained in:
parent
2fb2f7ca7b
commit
e3b9754d59
16 changed files with 235 additions and 105 deletions
49
src/github.com/matrix-org/dendrite/appservice/api/query.go
Normal file
49
src/github.com/matrix-org/dendrite/appservice/api/query.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2018 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package api contains methods used by dendrite components in multi-process
|
||||
// mode to send requests to the appservice component, typically in order to ask
|
||||
// an application service for some information.
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// AppServiceQueryAPI is used to query user and room alias data from application
|
||||
// services
|
||||
type AppServiceQueryAPI interface {
|
||||
// TODO: Check whether a room alias exists within any application service namespaces
|
||||
// TODO: QueryUserIDExists
|
||||
}
|
||||
|
||||
// httpAppServiceQueryAPI contains the URL to an appservice query API and a
|
||||
// reference to a httpClient used to reach it
|
||||
type httpAppServiceQueryAPI struct {
|
||||
appserviceURL string
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// NewAppServiceQueryAPIHTTP creates a AppServiceQueryAPI implemented by talking
|
||||
// to a HTTP POST API.
|
||||
// If httpClient is nil then it uses http.DefaultClient
|
||||
func NewAppServiceQueryAPIHTTP(
|
||||
appserviceURL string,
|
||||
httpClient *http.Client,
|
||||
) AppServiceQueryAPI {
|
||||
if httpClient == nil {
|
||||
httpClient = http.DefaultClient
|
||||
}
|
||||
return &httpAppServiceQueryAPI{appserviceURL, httpClient}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue