Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FinClip
ligase
提交
2fadb9e4
ligase
项目概览
FinClip
/
ligase
通知
37
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ligase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2fadb9e4
编写于
4月 20, 2017
作者:
K
Kegsay
提交者:
GitHub
4月 20, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make it possible to point Riot at Dendrite (#74)
上级
43d1e94e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
165 addition
and
1 deletion
+165
-1
src/github.com/matrix-org/dendrite/clientapi/readers/login.go
...github.com/matrix-org/dendrite/clientapi/readers/login.go
+76
-0
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
...thub.com/matrix-org/dendrite/clientapi/routing/routing.go
+83
-0
vendor/manifest
vendor/manifest
+1
-1
vendor/src/github.com/matrix-org/util/json.go
vendor/src/github.com/matrix-org/util/json.go
+5
-0
未找到文件。
src/github.com/matrix-org/dendrite/clientapi/readers/login.go
0 → 100644
浏览文件 @
2fadb9e4
package
readers
import
(
"fmt"
"github.com/matrix-org/dendrite/clientapi/config"
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/util"
"net/http"
)
type
loginFlows
struct
{
Flows
[]
flow
`json:"flows"`
}
type
flow
struct
{
Type
string
`json:"type"`
Stages
[]
string
`json:"stages"`
}
type
passwordRequest
struct
{
User
string
`json:"user"`
Password
string
`json:"password"`
}
type
loginResponse
struct
{
UserID
string
`json:"user_id"`
AccessToken
string
`json:"access_token"`
HomeServer
string
`json:"home_server"`
}
func
passwordLogin
()
loginFlows
{
f
:=
loginFlows
{}
s
:=
flow
{
"m.login.password"
,
[]
string
{
"m.login.password"
}}
f
.
Flows
=
append
(
f
.
Flows
,
s
)
return
f
}
// Login implements GET and POST /login
func
Login
(
req
*
http
.
Request
,
cfg
config
.
ClientAPI
)
util
.
JSONResponse
{
if
req
.
Method
==
"GET"
{
// TODO: support other forms of login other than password, depending on config options
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
passwordLogin
(),
}
}
else
if
req
.
Method
==
"POST"
{
var
r
passwordRequest
resErr
:=
httputil
.
UnmarshalJSONRequest
(
req
,
&
r
)
if
resErr
!=
nil
{
return
*
resErr
}
if
r
.
User
==
""
{
return
util
.
JSONResponse
{
Code
:
400
,
JSON
:
jsonerror
.
BadJSON
(
"'user' must be supplied."
),
}
}
// TODO: Check username and password properly
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
loginResponse
{
UserID
:
makeUserID
(
r
.
User
,
cfg
.
ServerName
),
AccessToken
:
makeUserID
(
r
.
User
,
cfg
.
ServerName
),
// FIXME: token is the user ID for now
HomeServer
:
cfg
.
ServerName
,
},
}
}
return
util
.
JSONResponse
{
Code
:
405
,
JSON
:
jsonerror
.
NotFound
(
"Bad method"
),
}
}
func
makeUserID
(
localpart
,
domain
string
)
string
{
return
fmt
.
Sprintf
(
"@%s:%s"
,
localpart
,
domain
)
}
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
浏览文件 @
2fadb9e4
package
routing
package
routing
import
(
import
(
"encoding/json"
"net/http"
"net/http"
"github.com/gorilla/mux"
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/clientapi/config"
"github.com/matrix-org/dendrite/clientapi/config"
"github.com/matrix-org/dendrite/clientapi/producers"
"github.com/matrix-org/dendrite/clientapi/producers"
"github.com/matrix-org/dendrite/clientapi/readers"
"github.com/matrix-org/dendrite/clientapi/writers"
"github.com/matrix-org/dendrite/clientapi/writers"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/util"
"github.com/matrix-org/util"
...
@@ -43,6 +45,87 @@ func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.ClientAPI
...
@@ -43,6 +45,87 @@ func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.ClientAPI
})),
})),
)
)
// Stub endpoints required by Riot
r0mux
.
Handle
(
"/login"
,
make
(
"login"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
return
readers
.
Login
(
req
,
cfg
)
})),
)
r0mux
.
Handle
(
"/pushrules/"
,
make
(
"push_rules"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Implement push rules API
res
:=
json
.
RawMessage
(
`{
"global": {
"content": [],
"override": [],
"room": [],
"sender": [],
"underride": []
}
}`
)
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
&
res
,
}
})),
)
r0mux
.
Handle
(
"/user/{userID}/filter"
,
make
(
"make_filter"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Persist filter and return filter ID
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{}{},
}
})),
)
r0mux
.
Handle
(
"/user/{userID}/filter/{filterID}"
,
make
(
"filter"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Retrieve filter based on ID
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{}{},
}
})),
)
// Riot user settings
r0mux
.
Handle
(
"/profile/{userID}"
,
make
(
"profile"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Get profile data for user ID
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{}{},
}
})),
)
r0mux
.
Handle
(
"/account/3pid"
,
make
(
"account_3pid"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Get 3pid data for user ID
res
:=
json
.
RawMessage
(
`{"threepids":[]}`
)
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
&
res
,
}
})),
)
// Riot logs get flooded unless this is handled
r0mux
.
Handle
(
"/presence/{userID}/status"
,
make
(
"presence"
,
util
.
NewJSONRequestHandler
(
func
(
req
*
http
.
Request
)
util
.
JSONResponse
{
// TODO: Set presence (probably the responsibility of a presence server not clientapi)
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{}{},
}
})),
)
servMux
.
Handle
(
"/metrics"
,
prometheus
.
Handler
())
servMux
.
Handle
(
"/metrics"
,
prometheus
.
Handler
())
servMux
.
Handle
(
"/api/"
,
http
.
StripPrefix
(
"/api"
,
apiMux
))
servMux
.
Handle
(
"/api/"
,
http
.
StripPrefix
(
"/api"
,
apiMux
))
}
}
...
...
vendor/manifest
浏览文件 @
2fadb9e4
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
{
{
"importpath": "github.com/matrix-org/util",
"importpath": "github.com/matrix-org/util",
"repository": "https://github.com/matrix-org/util",
"repository": "https://github.com/matrix-org/util",
"revision": "
ec8896cd7d9ba6de6143c5f123d1e45413657e7
d",
"revision": "
bc9d5e2d2f68a2ca279fce0fa2f28a91ecf301e
d",
"branch": "master"
"branch": "master"
},
},
{
{
...
...
vendor/src/github.com/matrix-org/util/json.go
浏览文件 @
2fadb9e4
...
@@ -111,6 +111,11 @@ func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc {
...
@@ -111,6 +111,11 @@ func MakeJSONAPI(handler JSONRequestHandler) http.HandlerFunc {
logger
:=
GetLogger
(
req
.
Context
())
logger
:=
GetLogger
(
req
.
Context
())
logger
.
Print
(
"Incoming request"
)
logger
.
Print
(
"Incoming request"
)
if
req
.
Method
==
"OPTIONS"
{
SetCORSHeaders
(
w
)
w
.
WriteHeader
(
200
)
return
}
res
:=
handler
.
OnIncomingRequest
(
req
)
res
:=
handler
.
OnIncomingRequest
(
req
)
// Set common headers returned regardless of the outcome of the request
// Set common headers returned regardless of the outcome of the request
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录