<commit_before>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package server

// TODO(ericsnow) Eliminate the apiserver dependencies, if possible.

import (
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/juju/errors"

	"github.com/juju/juju/apiserver/common"
	"github.com/juju/juju/apiserver/params"
)

// TODO(ericsnow) Define the HTTPHandlerConstraints here? Perhaps
// even the HTTPHandlerSpec?

// LegacyHTTPHandler is the HTTP handler for the resources endpoint. We
// use it rather than wrapping the functions since API HTTP endpoints
// must handle *all* HTTP methods.
type LegacyHTTPHandler struct {
	// Username is the username associated with the request.
	Username string

	// Connect opens a connection to state resources.
	Connect func(*http.Request) (DataStore, error)

	// HandleUpload provides the upload functionality.
	HandleUpload func(string, DataStore, *http.Request) error
}

// TODO(ericsnow) Can username be extracted from the request?<commit_msg>Add arg names to HandleUpload().<commit_after>// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package server

// TODO(ericsnow) Eliminate the apiserver dependencies, if possible.

import (
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/juju/errors"

	"github.com/juju/juju/apiserver/common"
	"github.com/juju/juju/apiserver/params"
)

// TODO(ericsnow) Define the HTTPHandlerConstraints here? Perhaps
// even the HTTPHandlerSpec?

// LegacyHTTPHandler is the HTTP handler for the resources endpoint. We
// use it rather than wrapping the functions since API HTTP endpoints
// must handle *all* HTTP methods.
type LegacyHTTPHandler struct {
	// Username is the username associated with the request.
	Username string

	// Connect opens a connection to state resources.
	Connect func(*http.Request) (DataStore, error)

	// HandleUpload provides the upload functionality.
	HandleUpload func(username string, st DataStore, req *http.Request) error
}

// TODO(ericsnow) Can username be extracted from the request?
{'fraction_non_alphanumeric': 0.09003370245546462, 'fraction_numerical': 0.004814636494944632, 'mean_word_length': 4.287531806615776, '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': '3842878', 'n_tokens_mistral': 630, 'n_tokens_neox': 595, 'n_words': 220}