mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Split Handler into Handler and APIHandler
This commit is contained in:
25
web/handler_helpers.go
Normal file
25
web/handler_helpers.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/qiangxue/fasthttp-routing"
|
||||
)
|
||||
|
||||
func makeURLResponse(c *routing.Context, uid []byte, url []byte) URLResponse {
|
||||
return URLResponse{
|
||||
UID: string(uid),
|
||||
URL: makeShortURL(c, uid),
|
||||
Target: string(url),
|
||||
}
|
||||
}
|
||||
|
||||
func makeShortURL(c *routing.Context, uid []byte) string {
|
||||
shortURL := &url.URL{
|
||||
Scheme: "http",
|
||||
Host: string(c.Host()),
|
||||
Path: "/" + string(uid),
|
||||
}
|
||||
|
||||
return shortURL.String()
|
||||
}
|
||||
Reference in New Issue
Block a user