about summary refs log tree commit diff
path: root/src/http.go
blob: 3422992c26151079624e9fef4e805bb8eb4d2e29 (plain)
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
package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/gorilla/mux"
)

// setupHTTPServer sets up a http server
func setupHTTPServer() http.Server {
	r := mux.NewRouter()

	r.HandleFunc("/", indexHandler)
	r.HandleFunc("/api/found", apiFoundHandler)

	return http.Server{
		Addr:    fmt.Sprintf("0.0.0.0:%d", httpServerPort),
		Handler: r,
	}
}

// indexHandler handles requests to the / endpoint
func indexHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "%s", "FUZZ!")
}

// httpStartServer starts the http server
func httpStartServer() {
	log.Printf("%s Starting the http server", green("[i]"))

	// setup the http server and start it
	httpServer := setupHTTPServer()
	log.Fatalln(httpServer.ListenAndServe())

	log.Printf("%s Done starting the http server", boldGreen("[+]"))
}

// handle requests to the /api/found endpoint
func apiFoundHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")
}