2022-02-21 20:51:41 +01:00
|
|
|
module server
|
2022-01-11 21:18:33 +01:00
|
|
|
|
|
|
|
import net.http
|
|
|
|
|
2022-04-30 20:22:03 +02:00
|
|
|
// is_authorized checks whether the provided API key is correct.
|
2022-01-11 21:18:33 +01:00
|
|
|
fn (mut app App) is_authorized() bool {
|
|
|
|
x_header := app.req.header.get_custom('X-Api-Key', http.HeaderQueryConfig{ exact: true }) or {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-02-21 20:40:13 +01:00
|
|
|
return x_header.trim_space() == app.conf.api_key
|
2022-01-11 21:18:33 +01:00
|
|
|
}
|