mirror of
https://github.com/aykhans/oh-my-url.git
synced 2025-09-05 04:43:35 +00:00
🔨 Refactor URL handling logic and remove unused variables
This commit is contained in:
@@ -8,13 +8,11 @@ import (
|
||||
)
|
||||
|
||||
type HandlerCreate struct {
|
||||
DB db.DB
|
||||
ForwardDomain string
|
||||
DB db.DB
|
||||
}
|
||||
|
||||
type HandlerForward struct {
|
||||
DB db.DB
|
||||
CreateDomain string
|
||||
DB db.DB
|
||||
}
|
||||
|
||||
func FaviconHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@@ -2,6 +2,7 @@ package httpHandlers
|
||||
|
||||
import (
|
||||
"github.com/aykhans/oh-my-url/app/utils"
|
||||
"github.com/aykhans/oh-my-url/app/config"
|
||||
"html/template"
|
||||
"net/http"
|
||||
netUrl "net/url"
|
||||
@@ -54,7 +55,7 @@ func (hl *HandlerCreate) UrlCreate(w http.ResponseWriter, r *http.Request) {
|
||||
InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
shortedURL, err := netUrl.JoinPath(hl.ForwardDomain, key)
|
||||
shortedURL, err := netUrl.JoinPath(config.GetForwardDomain(), key)
|
||||
if err != nil {
|
||||
InternalServerError(w, err)
|
||||
return
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package httpHandlers
|
||||
|
||||
import (
|
||||
"github.com/aykhans/oh-my-url/app/config"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
@@ -12,7 +13,7 @@ func (hl *HandlerForward) UrlForward(w http.ResponseWriter, r *http.Request) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
} else if segments[1] == "" {
|
||||
http.Redirect(w, r, hl.CreateDomain, http.StatusMovedPermanently)
|
||||
http.Redirect(w, r, config.GetCreateDomain(), http.StatusMovedPermanently)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user