File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 23
23
}
24
24
)
25
25
26
- func Search (w http.ResponseWriter , r * http.Request ) {
26
+ // Handler for /search endpoint. Initiates a database connection, tries to find the url in the database with the
27
+ // required depth, and if it doesn't exist, initiate a crawl.
28
+ func SearchHandler (w http.ResponseWriter , r * http.Request ) {
27
29
w .Header ().Set ("Content-Type" , "application/json; charset=UTF-8" )
28
30
vars := mux .Vars (r )
29
31
depth , err := strconv .Atoi (vars ["depth" ])
Original file line number Diff line number Diff line change @@ -23,14 +23,15 @@ var DefinedRoutes = Routes{
23
23
"Initiate" ,
24
24
"GET" ,
25
25
"/search" ,
26
- Search ,
26
+ SearchHandler ,
27
27
[]string {
28
28
"url" , "{url}" ,
29
29
"depth" , "{depth}" ,
30
30
},
31
31
},
32
32
}
33
33
34
+ // Initiates a mux router object with custom HTTP Response logger.
34
35
func NewRouter () * mux.Router {
35
36
router := mux .NewRouter ().StrictSlash (true )
36
37
for _ , route := range DefinedRoutes {
You can’t perform that action at this time.
0 commit comments