<commit_before>package server

import (
	"encoding/json"
	"fmt"
	"github.com/viant/endly"
	"github.com/viant/toolbox"
	"log"
	"net/http"
)

//Request represents service request.
type Request struct {
	Data           map[string]interface{}
	ServiceRequest interface{}
}

//Response service response
type Response struct {
	Status   string
	Error    string
	Response interface{}
	Data     map[string]interface{}
}

//Server represents a server
type Server struct {
	port    string
	manager endly.Manager
}

func (s *Server) requestService(serviceName, action string, httpRequest *http.Request, httpResponse http.ResponseWriter) (*Response, error) {
	var service endly.Service
	var serviceRequest interface{}
	var err error
	service, err = s.manager.Service(serviceName)
	if err != nil {
		return nil, err
	}
	context := s.manager.NewContext(toolbox.NewContext())
	serviceRequest, err = context.NewRequest(serviceName, action)
	if err != nil {
		return nil, err
	}

	request := &Request{
		ServiceRequest: serviceRequest,
	}
	err = json.NewDecoder(httpRequest.Body).Decode(request)
	if err != nil {
		return nil, err
	}

	defer context.Close()
	state := context.State()
	state.Apply(request.Data)
	serviceResponse := service.Run(context, request.ServiceRequest)
	var response = &Response{
		Status:   serviceResponse.Status,
		Error:    serviceResponse.Error,<commit_msg>updated func signature<commit_after>package server

import (
	"encoding/json"
	"fmt"
	"github.com/viant/endly"
	"github.com/viant/toolbox"
	"log"
	"net/http"
)

//Request represents service request.
type Request struct {
	Data           map[string]interface{}
	ServiceRequest interface{}
}

//Response service response
type Response struct {
	Status   string
	Error    string
	Response interface{}
	Data     map[string]interface{}
}

//Server represents a server
type Server struct {
	port    string
	manager endly.Manager
}

func (s *Server) requestService(serviceName, action string, httpRequest *http.Request, httpResponse http.ResponseWriter) (*Response, error) {
	var service endly.Service
	var serviceRequest interface{}
	var err error
	service, err = s.manager.Service(serviceName)
	if err != nil {
		return nil, err
	}
	context := s.manager.NewContext(toolbox.NewContext())
	serviceRequest, err = context.NewRequest(serviceName, action, map[string]interface{}{})
	if err != nil {
		return nil, err
	}

	request := &Request{
		ServiceRequest: serviceRequest,
	}
	err = json.NewDecoder(httpRequest.Body).Decode(request)
	if err != nil {
		return nil, err
	}

	defer context.Close()
	state := context.State()
	state.Apply(request.Data)
	serviceResponse := service.Run(context, request.ServiceRequest)
	var response = &Response{
		Status:   serviceResponse.Status,
		Error:    serviceResponse.Error,
{'fraction_non_alphanumeric': 0.1100685673042223, 'fraction_numerical': 0.0, 'mean_word_length': 4.372093023255814, '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': '3257333', 'n_tokens_mistral': 866, 'n_tokens_neox': 849, 'n_words': 230}