api_key.go 703 B

12345678910111213141516171819202122232425262728293031
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package form // import "miniflux.app/v2/internal/ui/form"
  4. import (
  5. "net/http"
  6. "miniflux.app/v2/internal/locale"
  7. )
  8. // APIKeyForm represents the API Key form.
  9. type APIKeyForm struct {
  10. Description string
  11. }
  12. // Validate makes sure the form values are valid.
  13. func (a APIKeyForm) Validate() *locale.LocalizedError {
  14. if a.Description == "" {
  15. return locale.NewLocalizedError("error.fields_mandatory")
  16. }
  17. return nil
  18. }
  19. // NewAPIKeyForm returns a new APIKeyForm.
  20. func NewAPIKeyForm(r *http.Request) *APIKeyForm {
  21. return &APIKeyForm{
  22. Description: r.FormValue("description"),
  23. }
  24. }