mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add sessions to API.
This commit is contained in:
parent
848556adbd
commit
8660c1a256
@ -45,6 +45,7 @@ func (api *ApiManagerCtx) Route(r types.Router) {
|
|||||||
|
|
||||||
r.Post("/logout", api.Logout)
|
r.Post("/logout", api.Logout)
|
||||||
r.Get("/whoami", api.Whoami)
|
r.Get("/whoami", api.Whoami)
|
||||||
|
r.Get("/sessions", api.Sessions)
|
||||||
|
|
||||||
membersHandler := members.New(api.members)
|
membersHandler := members.New(api.members)
|
||||||
r.Route("/members", membersHandler.Route)
|
r.Route("/members", membersHandler.Route)
|
||||||
|
@ -81,3 +81,16 @@ func (api *ApiManagerCtx) Whoami(w http.ResponseWriter, r *http.Request) error {
|
|||||||
State: session.State(),
|
State: session.State(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *ApiManagerCtx) Sessions(w http.ResponseWriter, r *http.Request) error {
|
||||||
|
sessions := []SessionDataPayload{}
|
||||||
|
for _, session := range api.sessions.List() {
|
||||||
|
sessions = append(sessions, SessionDataPayload{
|
||||||
|
ID: session.ID(),
|
||||||
|
Profile: session.Profile(),
|
||||||
|
State: session.State(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.HttpSuccess(w, sessions)
|
||||||
|
}
|
||||||
|
19
openapi.yaml
19
openapi.yaml
@ -116,6 +116,25 @@ paths:
|
|||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
'403':
|
'403':
|
||||||
$ref: '#/components/responses/Forbidden'
|
$ref: '#/components/responses/Forbidden'
|
||||||
|
/api/sessions:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- session
|
||||||
|
summary: get sessions
|
||||||
|
operationId: sessionsGet
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: OK
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/SessionData'
|
||||||
|
'401':
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
'403':
|
||||||
|
$ref: '#/components/responses/Forbidden'
|
||||||
|
|
||||||
#
|
#
|
||||||
# room
|
# room
|
||||||
|
Loading…
Reference in New Issue
Block a user