MCPcopy Index your code
hub / github.com/gotify/server / CreateClient

Method CreateClient

api/client.go:139–153  ·  view source on GitHub ↗

CreateClient creates a client and returns the access token. swagger:operation POST /client client createClient Create a client. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: [

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

137// schema:
138// $ref: "#/definitions/Error"
139func (a *ClientAPI) CreateClient(ctx *gin.Context) {
140 clientParams := ClientParams{}
141 if err := ctx.Bind(&clientParams); err == nil {
142 client := model.Client{
143 Name: clientParams.Name,
144 Token: auth.GenerateNotExistingToken(generateClientToken, a.clientExists),
145 UserID: auth.GetUserID(ctx),
146 }
147
148 if success := successOrAbort(ctx, 500, a.DB.CreateClient(&client)); !success {
149 return
150 }
151 ctx.JSON(200, client)
152 }
153}
154
155// GetClients returns all clients a user has.
156// swagger:operation GET /client client getClients

Callers

nothing calls this directly

Calls 4

GenerateNotExistingTokenFunction · 0.92
GetUserIDFunction · 0.92
successOrAbortFunction · 0.85
CreateClientMethod · 0.65

Tested by

no test coverage detected