-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (47 loc) · 1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"net/http"
"io/ioutil"
"encoding/json"
"github.com/franela/goreq"
"github.com/joho/godotenv"
"log"
"os"
)
type envObj struct {
PORT string
URL string
}
func loadEnv() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file, see .env.example")
return false
}
env := &envObj{
PORT = os.Getenv("PORT"),
URL = os.Getenv("URL")
}
return env
}
func elk_search(w http.ResponseWriter, r *http.Request) {
res, err := goreq.Request{
Method: "POST",
Uri: "http://localhost:9200/new-catalog/_search",
Compression: goreq.Gzip(),
ShowDebug: true,
}.Do()
// res.Response will contain the original http.Response structure
fmt.Println("<h1>Title: Test Site</h1>")
fmt.Println(res.Response, err)
//return res.Response
}
func init() {
fmt.Printf("Started server at http://localhost%v.\n", port)
http.HandleFunc("/", get_content)
http.ListenAndServe(port, nil)
}
func main() {
env = loadEnv()
}