MCPcopy
hub / github.com/tinode/chat / getAPIKey

Function getAPIKey

server/http.go:301–326  ·  view source on GitHub ↗

Get API key from an HTTP request.

(req *http.Request)

Source from the content-addressed store, hash-verified

299
300// Get API key from an HTTP request.
301func getAPIKey(req *http.Request) string {
302 // Check header.
303 apikey := req.Header.Get("X-Tinode-APIKey")
304 if apikey != "" {
305 return apikey
306 }
307
308 // Check URL query parameters.
309 apikey = req.URL.Query().Get("apikey")
310 if apikey != "" {
311 return apikey
312 }
313
314 // Check form values.
315 apikey = req.FormValue("apikey")
316 if apikey != "" {
317 return apikey
318 }
319
320 // Check cookies.
321 if c, err := req.Cookie("apikey"); err == nil {
322 apikey = c.Value
323 }
324
325 return apikey
326}
327
328// Extracts authorization credentials from an HTTP request.
329// Returns authentication method and secret.

Callers 4

serveWebSocketFunction · 0.85
serveLongPollFunction · 0.85
largeFileServeHTTPFunction · 0.85
largeFileReceiveHTTPFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…