summaryrefslogtreecommitdiffstats
path: root/modules/avatar/avatar.go
diff options
context:
space:
mode:
authorskyblue <ssx205@gmail.com>2014-03-26 21:26:31 +0800
committerskyblue <ssx205@gmail.com>2014-03-26 21:26:31 +0800
commit4662a73ac34adeeeb6fc48ba6ac69b6a4adf18bc (patch)
tree6dc79a28443c9c3688cc6e1b2469f64395e3067b /modules/avatar/avatar.go
parent409e4cde7a379bbdbe53367b3726f64b80aed0eb (diff)
downloadgitea-4662a73ac34adeeeb6fc48ba6ac69b6a4adf18bc.tar.gz
gitea-4662a73ac34adeeeb6fc48ba6ac69b6a4adf18bc.zip
name change of avatar
Diffstat (limited to 'modules/avatar/avatar.go')
-rw-r--r--modules/avatar/avatar.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go
index 449c9656dc..06e2c1385b 100644
--- a/modules/avatar/avatar.go
+++ b/modules/avatar/avatar.go
@@ -9,7 +9,7 @@ It is recommend to use this way
cacheDir := "./cache"
defaultImg := "./default.jpg"
- http.Handle("/avatar/", avatar.HttpHandler(cacheDir, defaultImg))
+ http.Handle("/avatar/", avatar.CacheServer(cacheDir, defaultImg))
*/
package avatar
@@ -135,12 +135,12 @@ func (this *Avatar) UpdateTimeout(timeout time.Duration) error {
return err
}
-type avatarHandler struct {
+type service struct {
cacheDir string
altImage string
}
-func (this *avatarHandler) mustInt(r *http.Request, defaultValue int, keys ...string) int {
+func (this *service) mustInt(r *http.Request, defaultValue int, keys ...string) int {
var v int
for _, k := range keys {
if _, err := fmt.Sscanf(r.FormValue(k), "%d", &v); err == nil {
@@ -150,7 +150,7 @@ func (this *avatarHandler) mustInt(r *http.Request, defaultValue int, keys ...st
return defaultValue
}
-func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+func (this *service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
urlPath := r.URL.Path
hash := urlPath[strings.LastIndex(urlPath, "/")+1:]
size := this.mustInt(r, 80, "s", "size") // default size = 80*80
@@ -183,9 +183,9 @@ func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
-// http.Handle("/avatar/", avatar.HttpHandler("./cache"))
-func HttpHandler(cacheDir string, defaultImgPath string) http.Handler {
- return &avatarHandler{
+// http.Handle("/avatar/", avatar.CacheServer("./cache"))
+func CacheServer(cacheDir string, defaultImgPath string) http.Handler {
+ return &service{
cacheDir: cacheDir,
altImage: defaultImgPath,
}