-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2755a57
commit 92aa6ad
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import "net/http" | ||
|
||
type RandomResponse struct { | ||
Success bool `json:"success"` | ||
Message string `json:"message"` | ||
Domain string `json:"domain"` | ||
Notice string `json:"notice"` | ||
} | ||
|
||
func randomHandler(w http.ResponseWriter, r *http.Request) { | ||
|
||
retVal := RandomResponse{} | ||
retVal.Notice = "Free for light, non-commericial use. For heavy or commercial use, please contact us." | ||
|
||
// pick a random key from the rankings map: since go tries to be non-deterministic, we'll just pick the first one | ||
for k := range rankings { | ||
retVal.Domain = k | ||
break | ||
} | ||
|
||
retVal.Success = true | ||
retVal.Message = "OK" | ||
|
||
handleJson(w, r, retVal) | ||
} |