docs.go 666 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
package routes

import (
	"net/http"

	"github.com/go-chi/docgen"
)

func (h Routes) DocsHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(http.StatusOK)
12
	docs := docgen.MarkdownRoutesDoc(h.router, docgen.MarkdownOpts{
13 14 15 16 17 18
		ProjectPath: "github.com/ethereum-optimism/optimism/indexer",
		// Intro text included at the top of the generated markdown file.
		Intro: "Generated documentation for Optimism indexer",
	})
	_, err := w.Write([]byte(docs))
	if err != nil {
19
		h.logger.Error("error writing docs", "err", err)
20 21 22
		http.Error(w, "Internal server error fetching docs", http.StatusInternalServerError)
	}
}