diff --git a/example/example_test.go b/example/example_test.go index 5457870..3c20e44 100644 --- a/example/example_test.go +++ b/example/example_test.go @@ -36,8 +36,7 @@ var cases = []struct { "page_number": 1, "result_per_page": 10 }`, - ExpectedJSONResBody: ` -{ + ExpectedJSONResBody: `{ "result": [ { "url": "query string", @@ -72,8 +71,7 @@ var cases = []struct { "result_per_page": 10 }`, ExpectedStatusCode: 500, - ExpectedJSONResBody: ` -{ + ExpectedJSONResBody: `{ "field": "field123", "error_count": 100 }`, @@ -86,8 +84,10 @@ var cases = []struct { "page_number": 1, "result_per_page": 10] }`, - ExpectedStatusCode: 400, - ExpectedJSONResBody: `{}`, + ExpectedStatusCode: 400, + ExpectedJSONResBody: `{ + +}`, }, { Name: "test response nil should panic", diff --git a/example/examplemain/main.go b/example/examplemain/main.go index 2925a2b..d0c7d44 100644 --- a/example/examplemain/main.go +++ b/example/examplemain/main.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" + "github.com/rs/cors" "github.com/theplant/appkit/log" "github.com/theplant/appkit/server" "github.com/theplant/prottp/example" @@ -14,7 +15,13 @@ func main() { mux := http.NewServeMux() example.Mount(mux) l := log.Default() + + c := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + }) + defaultmws := server.Compose( + c.Handler, server.DefaultMiddleware(l), )