You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
Updates from aurora.cam
This commit is contained in:
@ -305,6 +305,10 @@ flist=`grep -r "saas-starter-kit" * | awk -F ':' '{print $1}' | sort | uniq`
|
||||
for f in $flist; do echo $f; sed -i "" -e "s#saas-starter-kit#aurora-cam#g" $f; done
|
||||
|
||||
|
||||
flist=`grep -r "example-project" * | awk -F ':' '{print $1}' | sort | uniq`
|
||||
for f in $flist; do echo $f; sed -i "" -e "s#example-project#aurora-cam#g" $f; done
|
||||
|
||||
|
||||
```
|
||||
|
||||
3. Create a new AWS Policy with the following details:
|
||||
|
@ -49,6 +49,8 @@ COPY cmd/${service}/templates /templates
|
||||
ADD resources/templates/shared /templates/shared
|
||||
ADD fresh-auto-reload.conf /runner.conf
|
||||
|
||||
ENV TEMPLATE_DIR=/templates
|
||||
|
||||
WORKDIR ./cmd/${service}
|
||||
|
||||
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
|
||||
|
@ -32,6 +32,8 @@ COPY cmd/${service}/static /static
|
||||
ADD resources/templates/shared /templates/shared
|
||||
ADD fresh-auto-reload.conf /runner.conf
|
||||
|
||||
ENV TEMPLATE_DIR=/templates
|
||||
|
||||
WORKDIR ./cmd/${service}
|
||||
|
||||
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
|
||||
|
@ -818,7 +818,12 @@ func main() {
|
||||
tmplFuncs["S3ImgUrl"] = func(ctx context.Context, p string, size int) string {
|
||||
imgUrl := imgUrlFormatter(p)
|
||||
if cfg.Service.StaticFiles.ImgResizeEnabled {
|
||||
imgUrl, _ = img_resize.S3ImgUrl(ctx, redisClient, staticS3UrlFormatter, awsSession, cfg.Aws.S3BucketPublic, imgResizeS3KeyPrefix, imgUrl, size)
|
||||
var rerr error
|
||||
imgUrl, rerr = img_resize.S3ImgUrl(ctx, redisClient, staticS3UrlFormatter, awsSession, cfg.Aws.S3BucketPublic, imgResizeS3KeyPrefix, imgUrl, size)
|
||||
if rerr != nil {
|
||||
imgUrl = "error"
|
||||
log.Printf("main : S3ImgUrl : %s - %s\n", p, rerr)
|
||||
}
|
||||
}
|
||||
return imgUrl
|
||||
}
|
||||
@ -843,6 +848,10 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if web.RequestIsImage(r) {
|
||||
return err
|
||||
}
|
||||
|
||||
switch statusCode {
|
||||
case http.StatusUnauthorized:
|
||||
http.Redirect(w, r, "/user/login?redirect="+url.QueryEscape(r.RequestURI), http.StatusFound)
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
|
||||
// Headers
|
||||
const (
|
||||
HeaderAccept = "Accept"
|
||||
HeaderUpgrade = "Upgrade"
|
||||
HeaderXForwardedFor = "X-Forwarded-For"
|
||||
HeaderXForwardedProto = "X-Forwarded-Proto"
|
||||
@ -127,6 +128,11 @@ func RequestIsWebSocket(r *http.Request) bool {
|
||||
return strings.ToLower(upgrade) == "websocket"
|
||||
}
|
||||
|
||||
func RequestIsImage(r *http.Request) bool {
|
||||
accept := r.Header.Get(HeaderAccept)
|
||||
return strings.HasPrefix(accept, "image/")
|
||||
}
|
||||
|
||||
func RequestScheme(r *http.Request) string {
|
||||
// Can't use `r.Request.URL.Scheme`
|
||||
// See: https://groups.google.com/forum/#!topic/golang-nuts/pMUkBlQBDF0
|
||||
|
@ -191,6 +191,10 @@ func RenderError(ctx context.Context, w http.ResponseWriter, r *http.Request, er
|
||||
}
|
||||
v.StatusCode = webErr.Status
|
||||
|
||||
if RequestIsImage(r) {
|
||||
return nil
|
||||
}
|
||||
|
||||
resp := webErr.Response(ctx, true)
|
||||
|
||||
data := map[string]interface{}{
|
||||
|
@ -279,6 +279,11 @@ func NewTemplateRenderer(templateDir string, enableHotReload bool, globalViewDat
|
||||
// statusCode: the error method calls this function so allow the HTTP Status Code to be set
|
||||
// data: map[string]interface{} to allow including additional request and globally defined values.
|
||||
func (r *TemplateRenderer) Render(ctx context.Context, w http.ResponseWriter, req *http.Request, templateLayoutName, templateContentName, contentType string, statusCode int, data map[string]interface{}) error {
|
||||
// Not really anyway to render an image response using a template.
|
||||
if web.RequestIsImage(req) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the template has not been rendered yet or hot reload is enabled,
|
||||
// then parse the template files.
|
||||
t, ok := r.templates[templateContentName]
|
||||
|
Reference in New Issue
Block a user