Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
petaki committed Feb 14, 2025
1 parent 73bfe20 commit 7ab569c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions inertia.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (i *Inertia) Render(w http.ResponseWriter, r *http.Request, component strin
}
}

if i.isInertiaRequest(r) {
if r.Header.Get(HeaderInertia) != "" {
js, err := json.Marshal(page)
if err != nil {
return err
Expand Down Expand Up @@ -219,18 +219,14 @@ func (i *Inertia) Render(w http.ResponseWriter, r *http.Request, component strin

// Location function.
func (i *Inertia) Location(w http.ResponseWriter, r *http.Request, url string) {
if i.isInertiaRequest(r) {
if r.Header.Get(HeaderInertia) != "" {
w.Header().Set(HeaderLocation, url)
w.WriteHeader(http.StatusConflict)
} else {
http.Redirect(w, r, url, http.StatusFound)
}
}

func (i *Inertia) isInertiaRequest(r *http.Request) bool {
return r.Header.Get(HeaderInertia) != ""
}

func (i *Inertia) createRootTemplate() (*template.Template, error) {
if i.parsedTemplate != nil {
return i.parsedTemplate, nil
Expand Down

0 comments on commit 7ab569c

Please sign in to comment.