File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -54,19 +54,23 @@ func Handler(w http.ResponseWriter, r *http.Request) {
54
54
result = site .Search (search )
55
55
} else if list != "" {
56
56
log .Debug ("listing page " , list )
57
- pagenum , _ := strconv .Atoi (list )
57
+ pagenum , err := strconv .Atoi (list )
58
+ if err != nil {
59
+ http .Error (w , "Page must be a number" , http .StatusBadRequest )
60
+ }
58
61
result = site .List (pagenum )
59
62
}
60
63
61
64
// dump results
62
65
b , err := json .Marshal (result .Movies )
63
66
if err != nil {
64
67
log .Fatal ("failed to serialize response: " , err )
68
+ http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
65
69
}
66
70
enableCors (& w )
67
71
w .Header ().Add ("Content-Type" , "application/json" )
68
72
w .Write (b )
69
- log .Debug ("Completed search for" , search , list )
73
+ log .Debug ("Completed search for " , search , list )
70
74
}
71
75
72
76
func enableCors (w * http.ResponseWriter ) {
You can’t perform that action at this time.
0 commit comments