func search(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	text := r.FormValue("text")
	mode := r.FormValue("mode")
	records, path, recordsAmount, code, err := dbs.Search(dbPath, mode, text)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		Path          string      `json:"bucketsPath"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		false,
		false,
		false,
		path + " (Search \"" + text + "\")",
		recordsAmount,
		records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
search

Params: dbPath, text, mode ("regex" or "plain")
Return:
{
"prevBucket": bool,
"prevRecords": bool,
"nextRecords": bool,
"bucketsPath": string,
"recordsAmount": int,
"records": [
{
"type": "",
"key": "",
"value": ""
},
]
}
package web
import (
	"encoding/json"
	"fmt"
	"net/http"
	"regexp"
	"github.com/ShoshinNikita/log"
	"github.com/ShoshinNikita/boltBrowser/internal/db"
	"github.com/ShoshinNikita/boltBrowser/internal/dbs"
)
func openDB(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	readOnly := (r.FormValue("readOnly") == "true")
	reg := regexp.MustCompile(`\\\\|\\`)
	dbPath = reg.ReplaceAllString(dbPath, "/")
	_, code, err := dbs.OpenDB(dbPath, readOnly)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	w.WriteHeader(code)
	response := struct {
		DBPath string `json:"dbPath"`
	}{dbPath}
	escapeRecords(&response)
	json.NewEncoder(w).Encode(response)
}
func createDB(w http.ResponseWriter, r *http.Request) {
	path := r.FormValue("path")
	_, dbPath, code, err := dbs.CreateDB(path)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	w.WriteHeader(code)
	response := struct {
		DBPath string `json:"dbPath"`
	}{dbPath}
	escapeRecords(&response)
	json.NewEncoder(w).Encode(response)
}
func closeDB(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	code, err := dbs.CloseDB(dbPath)
	if err != nil {
		returnError(w, err, "", code)
	}
	w.WriteHeader(code)
}
func next(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	nextBucket := r.FormValue("bucket")
	data, code, err := dbs.NextBucket(dbPath, nextBucket)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		Path          string      `json:"bucketsPath"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.Path,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
func back(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	data, code, err := dbs.PrevBucket(dbPath)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		Path          string      `json:"bucketsPath"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.Path,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
func root(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	data, code, err := dbs.GetRoot(dbPath)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		Path          string      `json:"bucketsPath"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.Path,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
func databasesList(w http.ResponseWriter, r *http.Request) {
	list := dbs.GetDBsList()
	w.WriteHeader(http.StatusOK)
	json.NewEncoder(w).Encode(list)
}
func current(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	info, data, code, err := dbs.GetCurrent(dbPath)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		DB            dbs.DBInfo  `json:"db"`
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		Path          string      `json:"bucketsPath"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		info,
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.Path,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
func nextRecords(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	data, code, err := dbs.GetNextRecords(dbPath)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}
func prevRecords(w http.ResponseWriter, r *http.Request) {
	dbPath := r.FormValue("dbPath")
	data, code, err := dbs.GetPrevRecrods(dbPath)
	if err != nil {
		returnError(w, err, "", code)
		return
	}
	response := struct {
		PrevBucket    bool        `json:"prevBucket"`
		PrevRecords   bool        `json:"prevRecords"`
		NextRecords   bool        `json:"nextRecords"`
		RecordsAmount int         `json:"recordsAmount"`
		Records       []db.Record `json:"records"`
	}{
		data.PrevBucket,
		data.PrevRecords,
		data.NextRecords,
		data.RecordsAmount,
		data.Records,
	}
	escapeRecords(&response)
	w.WriteHeader(code)
	json.NewEncoder(w).Encode(response)
}