gosl.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. // gosl is a basic example of how to develop external web services for Second Life/OpenSimulator using the Go programming language.
  2. package main
  3. import (
  4. // "bufio" // replaced by the more sophisticated readline (gwyneth 20211106)
  5. "encoding/json"
  6. "fmt"
  7. "net/http"
  8. "net/http/fcgi"
  9. "os"
  10. "path/filepath"
  11. // "regexp"
  12. "strings"
  13. // "time"
  14. "github.com/dgraph-io/badger/v3"
  15. // "github.com/dgraph-io/badger/options"
  16. // "github.com/fsnotify/fsnotify"
  17. "github.com/google/uuid"
  18. "github.com/op/go-logging"
  19. flag "github.com/spf13/pflag"
  20. "github.com/spf13/viper"
  21. "github.com/syndtr/goleveldb/leveldb"
  22. "github.com/tidwall/buntdb"
  23. "gitlab.com/cznic/readline"
  24. // "gopkg.in/go-playground/validator.v9" // to validate UUIDs... and a lot of thinks
  25. "gopkg.in/natefinch/lumberjack.v2"
  26. )
  27. const NullUUID = "00000000-0000-0000-0000-000000000000" // always useful when we deal with SL/OpenSimulator...
  28. const databaseName = "gosl-database.db" // for BuntDB
  29. // Logging setup.
  30. var log = logging.MustGetLogger("gosl") // configuration for the go-logging logger, must be available everywhere
  31. var logFormat logging.Formatter
  32. // Opt is used for Badger database setup.
  33. var Opt badger.Options
  34. // AvatarUUID is the type that we store in the database; we keep a record from which grid it came from.
  35. // Field names need to be capitalised for JSON marshalling (it has to do with the way it works)
  36. // Note that we will store both UUID -> AvatarName *and* AvatarName -> UUID on the same database,
  37. //
  38. // thus the apparent redundancy in fields! (gwyneth 20211030)
  39. //
  40. // The 'validate' decorator is for usage with the go-playground validator, currently unused (gwyneth 20211031)
  41. type avatarUUID struct {
  42. AvatarName string `json:"name" form:"name" binding:"required" validate:"omitempty,alphanum"`
  43. UUID string `json:"key" form:"key" binding:"required" validate:"omitempty,uuid4_rfc4122"`
  44. Grid string `json:"grid" form:"grid" validate:"omitempty,alphanum"`
  45. }
  46. /*
  47. .__
  48. _____ _____ |__| ____
  49. / \\__ \ | |/ \
  50. | Y Y \/ __ \| | | \
  51. |__|_| (____ /__|___| /
  52. \/ \/ \/
  53. */
  54. // Configuration options
  55. type goslConfigOptions struct {
  56. BATCH_BLOCK int // how many entries to write to the database as a block; the bigger, the faster, but the more memory it consumes
  57. noMemory, isServer, isShell bool
  58. myDir, myPort, importFilename, database string
  59. dbNamePath string // for BuntDB
  60. logLevel, logFilename string // for logs
  61. maxSize, maxBackups, maxAge int // logs configuration option
  62. }
  63. var goslConfig goslConfigOptions
  64. var kv *badger.DB
  65. // loadConfiguration reads our configuration from a config.toml file
  66. func loadConfiguration() {
  67. fmt.Print("Reading gosl-basic configuration:") // note that we might not have go-logging active as yet, so we use fmt
  68. // Open our config file and extract relevant data from there
  69. err := viper.ReadInConfig() // Find and read the config file
  70. if err != nil {
  71. fmt.Println("error reading config file:", err)
  72. return // we might still get away with this!
  73. }
  74. viper.SetDefault("config.BATCH_BLOCK", 100000) // NOTE(gwyneth): the authors of say that 100000 is way too much for Badger // NOTE(gwyneth): let's see what happens with BuntDB
  75. goslConfig.BATCH_BLOCK = viper.GetInt("config.BATCH_BLOCK")
  76. viper.SetDefault("config.myPort", 3000)
  77. goslConfig.myPort = viper.GetString("config.myPort")
  78. viper.SetDefault("config.myDir", "slkvdb")
  79. goslConfig.myDir = viper.GetString("config.myDir")
  80. viper.SetDefault("config.isServer", false)
  81. goslConfig.isServer = viper.GetBool("config.isServer")
  82. viper.SetDefault("config.isShell", false)
  83. goslConfig.isShell = viper.GetBool("config.isShell")
  84. viper.SetDefault("config.database", "badger") // currently, badger, boltdb, leveldb
  85. goslConfig.database = viper.GetString("config.database")
  86. viper.SetDefault("options.importFilename", "") // must be empty by default
  87. goslConfig.importFilename = viper.GetString("options.importFilename")
  88. viper.SetDefault("options.noMemory", false)
  89. goslConfig.noMemory = viper.GetBool("options.noMemory")
  90. // Logging options
  91. viper.SetDefault("log.Filename", "gosl.log")
  92. goslConfig.logFilename = viper.GetString("log.Filename")
  93. viper.SetDefault("log.logLevel", "ERROR")
  94. goslConfig.logLevel = viper.GetString("log.logLevel")
  95. viper.SetDefault("log.MaxSize", 10)
  96. goslConfig.maxSize = viper.GetInt("log.MaxSize")
  97. viper.SetDefault("log.MaxBackups", 3)
  98. goslConfig.maxBackups = viper.GetInt("log.MaxBackups")
  99. viper.SetDefault("log.MaxAge", 28)
  100. goslConfig.maxAge = viper.GetInt("log.MaxAge")
  101. }
  102. // main() starts here.
  103. func main() {
  104. // Flag setup; can be overridden by config file.
  105. // TODO(gwyneth): I need to fix this to be the oher way round).
  106. goslConfig.myPort = *flag.String("port", "3000", "Server port")
  107. goslConfig.myDir = *flag.String("dir", "slkvdb", "Directory where database files are stored")
  108. goslConfig.isServer = *flag.Bool("server", false, "Run as server on port "+goslConfig.myPort)
  109. goslConfig.isShell = *flag.Bool("shell", false, "Run as an interactive shell")
  110. goslConfig.importFilename = *flag.String("import", "", "Import database from W-Hat (use the csv.bz2 versions)")
  111. goslConfig.database = *flag.String("database", "badger", "Database type (badger, buntdb, leveldb)")
  112. goslConfig.noMemory = *flag.Bool("nomemory", true, "Attempt to use only disk to save memory on Badger (important for shared webservers)")
  113. // Config viper, which reads in the configuration file every time it's needed.
  114. // Note that we need some hard-coded variables for the path and config file name.
  115. viper.SetConfigName("config")
  116. viper.SetConfigType("toml") // just to make sure; it's the same format as OpenSimulator (or MySQL) config files
  117. viper.AddConfigPath(".") // optionally look for config in the working directory
  118. viper.AddConfigPath("$HOME/go/src/git.gwynethllewelyn.net/GwynethLlewelyn/gosl-basics/") // that's how you'll have it
  119. loadConfiguration()
  120. // default is FastCGI
  121. flag.Parse()
  122. viper.BindPFlags(flag.CommandLine)
  123. // this will allow our configuration file to be 'read on demand'
  124. // TODO(gwyneth): There is something broken with this, no reason why... (gwyneth 20211026)
  125. // viper.WatchConfig()
  126. // viper.OnConfigChange(func(e fsnotify.Event) {
  127. // if goslConfig.isServer || goslConfig.isShell {
  128. // fmt.Println("Config file changed:", e.Name) // BUG(gwyneth): FastCGI cannot write to output
  129. // }
  130. // loadConfiguration()
  131. // })
  132. // NOTE(gwyneth): We cannot write to stdout if we're running as FastCGI, only to logs!
  133. if goslConfig.isServer || goslConfig.isShell {
  134. fmt.Println("gosl is starting...")
  135. }
  136. // This is mostly to deal with scoping issues below. (gwyneth 20211106)
  137. var err error
  138. // Setup the lumberjack rotating logger. This is because we need it for the go-logging logger when writing to files. (20170813)
  139. rotatingLogger := &lumberjack.Logger{
  140. Filename: goslConfig.logFilename,
  141. MaxSize: goslConfig.maxSize, // megabytes
  142. MaxBackups: goslConfig.maxBackups,
  143. MaxAge: goslConfig.maxAge, //days
  144. }
  145. // Set formatting for stderr and file (basically the same).
  146. logFormat := logging.MustStringFormatter(`%{color}%{time:2006/01/02 15:04:05.0} %{shortfile} - %{shortfunc} ▶ %{level:.4s}%{color:reset} %{message}`) // must be initialised or all hell breaks loose
  147. // Setup the go-logging Logger. Do **not** log to stderr if running as FastCGI!
  148. backendFile := logging.NewLogBackend(rotatingLogger, "", 0)
  149. backendFileFormatter := logging.NewBackendFormatter(backendFile, logFormat)
  150. backendFileLeveled := logging.AddModuleLevel(backendFileFormatter)
  151. theLogLevel, err := logging.LogLevel(goslConfig.logLevel)
  152. if err != nil {
  153. log.Warningf("could not set log level to %q — invalid?\nlogging.LogLevel() returned error %q\n", goslConfig.logLevel, err)
  154. } else {
  155. log.Debugf("requested file log level: %q\n", theLogLevel.String())
  156. backendFileLeveled.SetLevel(theLogLevel, "gosl") // we just send debug data to logs if we run asshell
  157. log.Debugf("file log level set to: %v\n", backendFileLeveled.GetLevel("gosl"))
  158. }
  159. if goslConfig.isServer || goslConfig.isShell {
  160. backendStderr := logging.NewLogBackend(os.Stderr, "", 0)
  161. backendStderrFormatter := logging.NewBackendFormatter(backendStderr, logFormat)
  162. backendStderrLeveled := logging.AddModuleLevel(backendStderrFormatter)
  163. log.Debugf("requested stderr log level: %q\n", theLogLevel.String())
  164. backendStderrLeveled.SetLevel(theLogLevel, "gosl")
  165. log.Debugf("stderr log level set to: %v\n", backendStderrLeveled.GetLevel("gosl"))
  166. }
  167. /*
  168. // deprecated, now we set it explicitly if desired
  169. if goslConfig.isShell {
  170. backendStderrLeveled.SetLevel(logging.DEBUG, "gosl") // shell is meant to be for debugging mostly
  171. } else {
  172. backendStderrLeveled.SetLevel(logging.INFO, "gosl")
  173. }
  174. logging.SetBackend(backendStderrLeveled, backendFileLeveled)
  175. } else {
  176. logging.SetBackend(backendFileLeveled) // FastCGI only logs to file
  177. }
  178. */
  179. // Check if this directory actually exists; if not, create it. Panic if something wrong happens (we cannot proceed without a valid directory for the database to be written)
  180. if stat, err := os.Stat(goslConfig.myDir); err == nil && stat.IsDir() {
  181. // path is a valid directory
  182. log.Debugf("valid directory: %q\n", goslConfig.myDir)
  183. } else {
  184. // try to create directory
  185. if err = os.Mkdir(goslConfig.myDir, 0700); err != nil {
  186. if err != os.ErrExist {
  187. checkErr(err)
  188. } else {
  189. log.Debugf("directory %q exists, no need to create it\n", goslConfig.myDir)
  190. }
  191. }
  192. log.Debugf("created new directory: %q\n", goslConfig.myDir)
  193. }
  194. // Special options configuration.
  195. // Currently, this is only needed for Badger v3, the others have much simpler configurations.
  196. // (gwyneth 20211106)
  197. switch goslConfig.database {
  198. case "badger":
  199. // Badger v3 - fully rewritten configuration (much simpler!!) (gwyneth 20211026)
  200. if goslConfig.noMemory {
  201. // use disk; note that unlike the others, Badger generates its own filenames,
  202. // we can only pass a _directory_... (gwyneth 20211027)
  203. goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, databaseName)
  204. // try to create directory
  205. if err = os.Mkdir(goslConfig.dbNamePath, 0700); err != nil {
  206. if err != os.ErrExist {
  207. checkErr(err)
  208. } else {
  209. log.Debugf("directory %q exists, no need to create it\n", goslConfig.dbNamePath)
  210. }
  211. } else {
  212. log.Debugf("created new directory: %q\n", goslConfig.dbNamePath)
  213. }
  214. Opt = badger.DefaultOptions(goslConfig.dbNamePath)
  215. log.Debugf("entering disk mode, Opt is %+v\n", Opt)
  216. } else {
  217. // Use only memory
  218. Opt = badger.LSMOnlyOptions("").WithInMemory(true)
  219. Opt.WithLevelSizeMultiplier(1)
  220. Opt.WithNumMemtables(1)
  221. Opt.WithValueDir(Opt.Dir) // probably not needed
  222. log.Debugf("entering memory-only mode, Opt is %+v\n", Opt)
  223. }
  224. // common config
  225. Opt.WithLogger(log) // set the internal logger to our own rotating logger
  226. Opt.WithLoggingLevel(badger.ERROR)
  227. goslConfig.BATCH_BLOCK = 1000 // try to import less at each time, it will take longer but hopefully work
  228. log.Info("trying to avoid too much memory consumption")
  229. // the other databases do not require any special configuration (for now)
  230. } // /switch
  231. // if importFilename isn't empty, this means we potentially have something to import.
  232. if goslConfig.importFilename != "" {
  233. log.Info("attempting to import", goslConfig.importFilename, "...")
  234. importDatabase(goslConfig.importFilename)
  235. log.Info("database finished import.")
  236. } else {
  237. // it's not an error if there is no name2key database available for import (gwyneth 20211027)
  238. log.Debug("no database configured for import")
  239. }
  240. // Prepare testing data! (common to all database types)
  241. // Note: this only works for shell/server; for FastCGI it's definitely overkill (gwyneth 20211106),
  242. // so we do it only for server/shell mode.
  243. if goslConfig.isServer || goslConfig.isShell {
  244. const testAvatarName = "Nobody Here"
  245. log.Infof("gosl started and logging is set up. Proceeding to test database (%s) at %q\n", goslConfig.database, goslConfig.myDir)
  246. // generate a random UUID (gwyneth2021103) (gwyneth 20211031)
  247. var (
  248. testUUID = uuid.New().String() // Random UUID (gwyneth 20211031 — from )
  249. testValue = avatarUUID{testAvatarName, testUUID, "all grids"}
  250. )
  251. jsonTestValue, err := json.Marshal(testValue)
  252. checkErrPanic(err) // something went VERY wrong
  253. // KVDB Initialisation & Tests
  254. // Each case is different
  255. switch goslConfig.database {
  256. case "badger":
  257. // Opt has already been set earlier. (gwyneth 20211106)
  258. kv, err := badger.Open(Opt)
  259. checkErrPanic(err) // should probably panic, cannot prep new database
  260. txn := kv.NewTransaction(true)
  261. err = txn.Set([]byte(testAvatarName), jsonTestValue)
  262. checkErrPanic(err)
  263. err = txn.Set([]byte(testUUID), jsonTestValue)
  264. checkErrPanic(err)
  265. err = txn.Commit()
  266. checkErrPanic(err)
  267. log.Debugf("badger SET %+v (json: %v)\n", testValue, string(jsonTestValue))
  268. kv.Close()
  269. case "buntdb":
  270. goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, databaseName)
  271. db, err := buntdb.Open(goslConfig.dbNamePath)
  272. checkErrPanic(err)
  273. err = db.Update(func(tx *buntdb.Tx) error {
  274. _, _, err := tx.Set(testAvatarName, string(jsonTestValue), nil)
  275. return err
  276. })
  277. checkErr(err)
  278. log.Debugf("buntdb SET %+v (json: %v)\n", testValue, string(jsonTestValue))
  279. db.Close()
  280. case "leveldb":
  281. goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, databaseName)
  282. db, err := leveldb.OpenFile(goslConfig.dbNamePath, nil)
  283. checkErrPanic(err)
  284. err = db.Put([]byte(testAvatarName), jsonTestValue, nil)
  285. checkErrPanic(err)
  286. log.Debugf("leveldb SET %+v (json: %v)\n", testValue, string(jsonTestValue))
  287. db.Close()
  288. } // /switch
  289. // common to all databases:
  290. key, grid := searchKVname(testAvatarName)
  291. log.Debugf("GET %q returned %q [grid %q]\n", testAvatarName, key, grid)
  292. log.Info("KV database seems fine.")
  293. if goslConfig.importFilename != "" {
  294. log.Info("attempting to import", goslConfig.importFilename, "...")
  295. importDatabase(goslConfig.importFilename)
  296. log.Info("database finished import.")
  297. } else {
  298. // it's not an error if there is no name2key database available for import (gwyneth 20211027)
  299. log.Debug("no database configured for import")
  300. }
  301. }
  302. if goslConfig.isShell {
  303. log.Info("starting to run as interactive shell")
  304. fmt.Println("Ctrl-C to quit, or just type \"quit\".")
  305. var err error // to avoid assigning text in a different scope (this is a bit awkward, but that's the problem with bi-assignment)
  306. var avatarName, avatarKey, gridName string
  307. rl, err := readline.New("enter avatar name or UUID: ")
  308. if err != nil {
  309. log.Criticalf("major readline issue preventing normal functioning; error was %q\n", err)
  310. }
  311. defer rl.Close()
  312. for {
  313. checkInput, err := rl.Readline()
  314. if err != nil || checkInput == "quit" { // io.EOF
  315. break
  316. }
  317. checkInput = strings.TrimRight(checkInput, "\r\n")
  318. // fmt.Printf("Ok, got %s length is %d and UUID is %v\n", checkInput, len(checkInput), isValidUUID(checkInput))
  319. if (len(checkInput) == 36) && isValidUUID(checkInput) {
  320. avatarName, gridName = searchKVUUID(checkInput)
  321. avatarKey = checkInput
  322. } else {
  323. avatarKey, gridName = searchKVname(checkInput)
  324. avatarName = checkInput
  325. }
  326. if avatarName != NullUUID && avatarKey != NullUUID {
  327. fmt.Println(avatarName, "which has UUID:", avatarKey, "comes from grid:", gridName)
  328. } else {
  329. fmt.Println("sorry, unknown input", checkInput)
  330. }
  331. }
  332. // never leaves until Ctrl-C or by typing `quit`. (gwyneth 20211106)
  333. log.Debug("interactive session finished.")
  334. } else if goslConfig.isServer {
  335. // set up routing.
  336. // NOTE(gwyneth): one function only because FastCGI seems to have problems with multiple handlers.
  337. http.HandleFunc("/", handler)
  338. log.Debug("directory for database:", goslConfig.myDir)
  339. log.Info("starting to run as web server on port :" + goslConfig.myPort)
  340. err := http.ListenAndServe(":"+goslConfig.myPort, nil) // set listen port
  341. checkErrPanic(err) // if it can't listen to all the above, then it has to abort anyway
  342. } else {
  343. // default is to run as FastCGI!
  344. // works like a charm thanks to http://www.dav-muz.net/blog/2013/09/how-to-use-go-and-fastcgi/
  345. log.Debug("http.DefaultServeMux is", http.DefaultServeMux)
  346. log.Info("Starting to run as FastCGI")
  347. if err := fcgi.Serve(nil, http.HandlerFunc(handler)); err != nil {
  348. log.Errorf("seems that we got an error from FCGI: %q\n", err)
  349. checkErrPanic(err)
  350. }
  351. }
  352. // we should never have reached this point!
  353. log.Error("unknown usage — this application may run as a standalone server, as a FastCGI application, or as an interactive shell")
  354. if goslConfig.isServer || goslConfig.isShell {
  355. flag.PrintDefaults()
  356. }
  357. }
  358. // handler deals with incoming queries and/or associates avatar names with keys depending on parameters.
  359. // Basically we check if both an avatar name and a UUID key has been received: if yes, this means a new entry;
  360. // - if just the avatar name was received, it means looking up its key;
  361. // - if just the key was received, it means looking up the name (not necessary since llKey2Name does that, but it's just to illustrate);
  362. // - if nothing is received, then return an error
  363. //
  364. // Note: to ensure quick lookups, we actually set *two* key/value pairs, one with avatar name/UUID,
  365. // the other with UUID/name — that way, we can efficiently search for *both* in the same database!
  366. // Theoretically, we could even have *two* KV databases, but that's too much trouble for the
  367. // sake of some extra efficiency (gwyneth 20211030)
  368. func handler(w http.ResponseWriter, r *http.Request) {
  369. if err := r.ParseForm(); err != nil {
  370. logErrHTTP(w, http.StatusNotFound, "no avatar and/or UUID received")
  371. return
  372. }
  373. // test first if this comes from Second Life or OpenSimulator
  374. /*
  375. if r.Header.Get("X-Secondlife-Region") == "" {
  376. logErrHTTP(w, http.StatusForbidden, "Sorry, this application only works inside Second Life.")
  377. return
  378. }
  379. */
  380. name := r.Form.Get("name") // can be empty
  381. key := r.Form.Get("key") // can be empty
  382. compat := r.Form.Get("compat") // compatibility mode with W-Hat
  383. var uuidToInsert avatarUUID
  384. messageToSL := "" // this is what we send back to SL - defined here due to scope issues.
  385. if name != "" {
  386. if key != "" {
  387. // we received both: add a new entry
  388. uuidToInsert.UUID = key
  389. uuidToInsert.Grid = r.Header.Get("X-Secondlife-Shard")
  390. jsonUUIDToInsert, err := json.Marshal(uuidToInsert)
  391. checkErr(err)
  392. switch goslConfig.database {
  393. case "badger":
  394. kv, err := badger.Open(Opt)
  395. checkErrPanic(err) // should probably panic
  396. txn := kv.NewTransaction(true)
  397. defer txn.Discard()
  398. err = txn.Set([]byte(name), jsonUUIDToInsert)
  399. checkErrPanic(err)
  400. err = txn.Commit()
  401. checkErrPanic(err)
  402. kv.Close()
  403. case "buntdb":
  404. db, err := buntdb.Open(goslConfig.dbNamePath)
  405. checkErrPanic(err)
  406. defer db.Close()
  407. err = db.Update(func(tx *buntdb.Tx) error {
  408. _, _, err := tx.Set(name, string(jsonUUIDToInsert), nil)
  409. return err
  410. })
  411. checkErr(err)
  412. case "leveldb":
  413. db, err := leveldb.OpenFile(goslConfig.dbNamePath, nil)
  414. checkErrPanic(err)
  415. err = db.Put([]byte(name), jsonUUIDToInsert, nil)
  416. checkErrPanic(err)
  417. db.Close()
  418. }
  419. messageToSL += "Added new entry for '" + name + "' which is: " + uuidToInsert.UUID + " from grid: '" + uuidToInsert.Grid + "'"
  420. } else {
  421. // we received a name: look up its UUID key and grid.
  422. key, grid := searchKVname(name)
  423. if compat == "false" {
  424. messageToSL += "UUID for '" + name + "' is: " + key + " from grid: '" + grid + "'"
  425. } else { // empty also means true!
  426. messageToSL += key
  427. }
  428. }
  429. } else if key != "" {
  430. // in this scenario, we have the UUID key but no avatar name: do the equivalent of a llKey2Name
  431. name, grid := searchKVUUID(key)
  432. if compat == "false" {
  433. messageToSL += "avatar name for " + key + "' is '" + name + "' on grid: '" + grid + "'"
  434. } else { // empty also means true!
  435. messageToSL += name
  436. }
  437. } else {
  438. // neither UUID key nor avatar received, this is an error
  439. logErrHTTP(w, http.StatusNotFound, "empty avatar name and UUID key received, cannot proceed")
  440. return
  441. }
  442. w.WriteHeader(http.StatusOK)
  443. w.Header().Set("Content-Type", "text/plain; charset=utf-8")
  444. fmt.Fprint(w, messageToSL)
  445. }