You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

swagger_json.go 744B

1234567891011121314151617181920212223242526
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package routers
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/modules/base"
  8. "code.gitea.io/gitea/modules/context"
  9. "code.gitea.io/gitea/modules/log"
  10. )
  11. // tplSwaggerV1Json swagger v1 json template
  12. const tplSwaggerV1Json base.TplName = "swagger/v1_json"
  13. // SwaggerV1Json render swagger v1 json
  14. func SwaggerV1Json(ctx *context.Context) {
  15. t := ctx.Render.TemplateLookup(string(tplSwaggerV1Json))
  16. ctx.Resp.Header().Set("Content-Type", "application/json")
  17. if err := t.Execute(ctx.Resp, ctx.Data); err != nil {
  18. log.Error("%v", err)
  19. ctx.Error(http.StatusInternalServerError)
  20. }
  21. }