Skip to content

Commit

Permalink
BREAKING: update WithGlobalResponseType to take
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt committed Dec 16, 2024
1 parent a256a7c commit fea421d
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 62 deletions.
2 changes: 1 addition & 1 deletion examples/full-app-gourmet/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (rs Resources) Setup(
fuego.WithAutoAuth(controller.LoginFunc),
fuego.WithTemplateFS(templates.FS),
fuego.WithTemplateGlobs("**/*.html", "**/**/*.html"),
fuego.WithGlobalResponseTypes(http.StatusForbidden, "Forbidden"),
fuego.WithGlobalResponseTypes(http.StatusForbidden, "Forbidden", fuego.Response{Type: fuego.HTTPError{}}),
}

options = append(serverOptions, options...)
Expand Down
9 changes: 9 additions & 0 deletions examples/petstore/lib/server.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package lib

import (
"net/http"

"github.com/go-fuego/fuego"
controller "github.com/go-fuego/fuego/examples/petstore/controllers"
"github.com/go-fuego/fuego/examples/petstore/services"
)

type NoContent struct {
Empty string `json:"-"`
}

func NewPetStoreServer(options ...func(*fuego.Server)) *fuego.Server {
options = append(options, fuego.WithGlobalResponseTypes(
http.StatusNoContent, "No Content", fuego.Response{Type: NoContent{}},
))
s := fuego.NewServer(options...)

petsResources := controller.PetsResources{
Expand Down
Loading

0 comments on commit fea421d

Please sign in to comment.