1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

First pass at reorganizing go code into sub-packages

This commit is contained in:
2017-10-04 19:35:59 -04:00
parent d9ddef250a
commit d0a5980b85
36 changed files with 145 additions and 117 deletions

23
internal/handlers/util.go Normal file
View File

@ -0,0 +1,23 @@
package handlers
import (
"fmt"
"net/http"
"strconv"
"strings"
)
func GetURLID(url string) (int64, error) {
pieces := strings.Split(strings.Trim(url, "/"), "/")
return strconv.ParseInt(pieces[len(pieces)-1], 10, 0)
}
func GetURLPieces(url string, format string, a ...interface{}) (int, error) {
url = strings.Replace(url, "/", " ", -1)
format = strings.Replace(format, "/", " ", -1)
return fmt.Sscanf(url, format, a...)
}
func WriteSuccess(w http.ResponseWriter) {
fmt.Fprint(w, "{}")
}