MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / javaScriptHttpEndpoint

Function javaScriptHttpEndpoint

rest/config_test.go:1649–1658  ·  view source on GitHub ↗

javaScriptHttpEndpoint returns a callable function to setup an HTTP endpoint that exposes the given JavaScript source and returns a teardown function to terminate the underlying httptest server instance.

(t *testing.T, js string)

Source from the content-addressed store, hash-verified

1647// the given JavaScript source and returns a teardown function to terminate the underlying
1648// httptest server instance.
1649func javaScriptHttpEndpoint(t *testing.T, js string) func() (path string, teardownFn func()) {
1650 return func() (path string, teardownFn func()) {
1651 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1652 _, err := fmt.Fprint(w, js)
1653 require.NoError(t, err)
1654 }))
1655 teardownFn = func() { ts.Close() }
1656 return ts.URL, teardownFn
1657 }
1658}
1659
1660// javaScriptHttpErrorEndpoint returns a callable function to setup an HTTP endpoint that always
1661// return StatusInternalServerError and a teardown function to terminate the underlying httptest

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected