Skip to content

Commit 9afcee5

Browse files
author
Steven Ayers
committed
Add api package function comments
1 parent 2be4f1a commit 9afcee5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

api/handlers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ type (
2323
}
2424
)
2525

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) {
2729
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
2830
vars := mux.Vars(r)
2931
depth, err := strconv.Atoi(vars["depth"])

api/routes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ var DefinedRoutes = Routes{
2323
"Initiate",
2424
"GET",
2525
"/search",
26-
Search,
26+
SearchHandler,
2727
[]string{
2828
"url", "{url}",
2929
"depth", "{depth}",
3030
},
3131
},
3232
}
3333

34+
// Initiates a mux router object with custom HTTP Response logger.
3435
func NewRouter() *mux.Router {
3536
router := mux.NewRouter().StrictSlash(true)
3637
for _, route := range DefinedRoutes {

0 commit comments

Comments
 (0)