<commit_before>package jsonrpc

import (
	"encoding/json"
	"log"

	"github.com/nbusy/neptulon"
)

// ReqCtx encapsulates connection, request, and reponse objects.
type ReqCtx struct {
	Conn *neptulon.Conn
	Res  interface{} // Response to be returned
	Err  *ResError   // Error to be returned
	Done bool        // If set, this will prevent further middleware from handling the request

	id     string          // message ID
	method string          // called method
	params json.RawMessage // request parameters
}

// Params reads request parameters into given object.
// Object should be passed by reference.
func (r *ReqCtx) Params(v interface{}) {
	if err := json.Unmarshal(r.params, v); err != nil {
		log.Fatal("Cannot deserialize request params:", err)
	}
}

// NotCtx encapsulates connection and notification objects.
type NotCtx struct {
	Conn *neptulon.Conn
	Done bool // If set, this will prevent further middleware from handling the request

	method string          // called method
	params json.RawMessage // notification parameters
}

// Params reads response parameters into given object.
// Object should be passed by reference.
func (r *NotCtx) Params(v interface{}) {
	if err := json.Unmarshal(r.params, v); err != nil {
		log.Fatal("Cannot deserialize notification params:", err)
	}
}

// ResCtx encapsulates connection and response objects.
type ResCtx struct {
	Conn *neptulon.Conn
	Done bool // if set, this will prevent further middleware from handling the request

	id     string          // message ID
	result json.RawMessage // result parameters

	code    int             // error code
	message string          // error message
	data    json.RawMessage // error data
}

// Result reads response result data into given object.
// Object should be passed by reference.
func (r *ResCtx) Result(v interface{}) {
	if err := json.Unmarshal(r.result, v); err != nil {
		log.Fatalln("Cannot deserialize response result:", err)
	}
}<commit_msg>fix context typo<commit_after>package jsonrpc

import (
	"encoding/json"
	"log"

	"github.com/nbusy/neptulon"
)

// ReqCtx encapsulates connection, request, and reponse objects.
type ReqCtx struct {
	Conn *neptulon.Conn
	Res  interface{} // Response to be returned
	Err  *ResError   // Error to be returned
	Done bool        // If set, this will prevent further middleware from handling the request

	id     string          // message ID
	method string          // called method
	params json.RawMessage // request parameters
}

// Params reads request parameters into given object.
// Object should be passed by reference.
func (r *ReqCtx) Params(v interface{}) {
	if r.params == nil {
		return
	}

	if err := json.Unmarshal(r.params, v); err != nil {
		log.Fatal("Cannot deserialize request params:", err)
	}
}

// NotCtx encapsulates connection and notification objects.
type NotCtx struct {
	Conn *neptulon.Conn
	Done bool // If set, this will prevent further middleware from handling the request

	method string          // called method
	params json.RawMessage // notification parameters
}

// Params reads response parameters into given object.
// Object should be passed by reference.
func (r *NotCtx) Params(v interface{}) {
	if r.params == nil {
		return
	}

	if err := json.Unmarshal(r.params, v); err != nil {
		log.Fatal("Cannot deserialize notification params:", err)
	}
}

// ResCtx encapsulates connection and response objects.
type ResCtx struct {
	Conn *neptulon.Conn
	Done bool // if set, this will prevent further middleware from handling the request

	id     string          // message ID
	result json.RawMessage // result parameters

	code    int             // error code
	message string          // error message
	data    json.RawMessage // error data
}

// Result reads response result data into given object.
// Object should be passed by reference.
func (r *ResCtx) Result(v interface{}) {
	if r.result == nil {
		return
	}

	if err := json.Unmarshal(r.result, v); err != nil {
		log.Fatalln("Cannot deserialize response result:", err)
	}
}
{'fraction_non_alphanumeric': 0.09319085487077534, 'fraction_numerical': 0.0, 'mean_word_length': 3.082150101419878, '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': '4694980', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1135, 'n_words': 452}