<commit_before>package verify

import (
	"net/http"
	"strings"

	"github.com/plimble/clover/oauth2"
	"go.uber.org/zap"
)

type VerifyHandlerRequest struct {
	AccessToken string
	Scopes      []string
}

type VerifyHandler struct {
	Storage oauth2.Storage
}

func New(storage oauth2.Storage) *VerifyHandler {
	return &VerifyHandler{storage}
}

func (h *VerifyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		oauth2.WriteJsonError(w, InvalidRequest("The request method must be POST"))
		return
	}

	if err := r.ParseForm(); err != nil {
		oauth2.WriteJsonError(w, InvalidRequest("Unable to parse form"))
		return
	}

	atoken := getAccessTokenFromRequest(r)

	req := &VerifyHandlerRequest{
		AccessToken: atoken,
		Scopes:      strings.Fields(r.Form.Get("scope")),
	}

	err := h.Verify(req)
	oauth2.Logger.Info("Verify AccessToken",
		zap.Any("VerifyHandlerRequest", req),
		zap.Any("error", err),
	)
	if err != nil {
		oauth2.WriteJsonError(w, err)
		return
	}

	oauth2.WriteJson(w, 200, nil)<commit_msg>delete log<commit_after>package verify

import (
	"net/http"
	"strings"

	"github.com/plimble/clover/oauth2"
)

type VerifyHandlerRequest struct {
	AccessToken string
	Scopes      []string
}

type VerifyHandler struct {
	Storage oauth2.Storage
}

func New(storage oauth2.Storage) *VerifyHandler {
	return &VerifyHandler{storage}
}

func (h *VerifyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		oauth2.WriteJsonError(w, InvalidRequest("The request method must be POST"))
		return
	}

	if err := r.ParseForm(); err != nil {
		oauth2.WriteJsonError(w, InvalidRequest("Unable to parse form"))
		return
	}

	atoken := getAccessTokenFromRequest(r)

	req := &VerifyHandlerRequest{
		AccessToken: atoken,
		Scopes:      strings.Fields(r.Form.Get("scope")),
	}

	err := h.Verify(req)

	if err != nil {
		oauth2.WriteJsonError(w, err)
		return
	}

	oauth2.WriteJson(w, 200, nil)
{'fraction_non_alphanumeric': 0.13134940995382247, 'fraction_numerical': 0.0107747562852745, 'mean_word_length': 4.401662049861496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6310569', 'n_tokens_mistral': 736, 'n_tokens_neox': 709, 'n_words': 151}