MCPcopy
hub / github.com/writefreely/writefreely / OAuth

Method OAuth

handle.go:615–644  ·  view source on GitHub ↗
(f handlerFunc)

Source from the content-addressed store, hash-verified

613}
614
615func (h *Handler) OAuth(f handlerFunc) http.HandlerFunc {
616 return func(w http.ResponseWriter, r *http.Request) {
617 h.handleOAuthError(w, r, func() error {
618 // TODO: return correct "success" status
619 status := 200
620 start := time.Now()
621
622 defer func() {
623 if e := recover(); e != nil {
624 log.Error("%s:\n%s", e, debug.Stack())
625 impart.WriteError(w, impart.HTTPError{http.StatusInternalServerError, "Something didn't work quite right."})
626 status = 500
627 }
628
629 log.Info(h.app.ReqLog(r, status, time.Since(start)))
630 }()
631
632 err := f(h.app.App(), w, r)
633 if err != nil {
634 if err, ok := err.(impart.HTTPError); ok {
635 status = err.Status
636 } else {
637 status = 500
638 }
639 }
640
641 return err
642 }())
643 }
644}
645
646func (h *Handler) AllReader(f handlerFunc) http.HandlerFunc {
647 return func(w http.ResponseWriter, r *http.Request) {

Callers 1

configureOauthRoutesFunction · 0.80

Calls 4

handleOAuthErrorMethod · 0.95
ReqLogMethod · 0.65
AppMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected