diff --git a/docs/advanced-guide/overriding-default/page.md b/docs/advanced-guide/overriding-default/page.md index b41234791..14b00120f 100644 --- a/docs/advanced-guide/overriding-default/page.md +++ b/docs/advanced-guide/overriding-default/page.md @@ -72,7 +72,8 @@ Response example: ``` ## Rendering Templates -GoFr allows rendering HTML/HTMX templates in handlers using the response.Template type. +GoFr makes it easy to render HTML and HTMX templates directly from your handlers using the response.Template type. +By convention, all template files—whether HTML or HTMX—should be placed inside a templates directory located at the root of your project. ### Example ```go diff --git a/docs/datasources/dgraph/page.md b/docs/datasources/dgraph/page.md index 3ad8dbb0a..4f64f8981 100644 --- a/docs/datasources/dgraph/page.md +++ b/docs/datasources/dgraph/page.md @@ -6,6 +6,15 @@ database. Any driver that implements the following interface can be added using ```go // Dgraph defines the methods for interacting with a Dgraph database. type Dgraph interface { + // ApplySchema applies or updates the complete database schema. + ApplySchema(ctx context.Context, schema string) error + + // AddOrUpdateField atomically creates or updates a single field definition. + AddOrUpdateField(ctx context.Context, fieldName, fieldType, directives string) error + + // DropField permanently removes a field/predicate and all its associated data. + DropField(ctx context.Context, fieldName string) error + // Query executes a read-only query in the Dgraph database and returns the result. Query(ctx context.Context, query string) (any, error) diff --git a/examples/grpc/grpc-client/client/health_client.go b/examples/grpc/grpc-client/client/health_client.go index 11950667a..5d5cbd2fd 100644 --- a/examples/grpc/grpc-client/client/health_client.go +++ b/examples/grpc/grpc-client/client/health_client.go @@ -1,4 +1,9 @@ // Code generated by gofr.dev/cli/gofr. DO NOT EDIT. +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + package client import ( diff --git a/examples/grpc/grpc-client/client/hello_client.go b/examples/grpc/grpc-client/client/hello_client.go index ea50c7fe3..cad05643b 100644 --- a/examples/grpc/grpc-client/client/hello_client.go +++ b/examples/grpc/grpc-client/client/hello_client.go @@ -1,4 +1,9 @@ // Code generated by gofr.dev/cli/gofr. DO NOT EDIT. +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + package client import ( diff --git a/examples/grpc/grpc-server/server/health_gofr.go b/examples/grpc/grpc-server/server/health_gofr.go index e6ea82387..dd6539e6b 100644 --- a/examples/grpc/grpc-server/server/health_gofr.go +++ b/examples/grpc/grpc-server/server/health_gofr.go @@ -1,4 +1,9 @@ // Code generated by gofr.dev/cli/gofr. DO NOT EDIT. +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + package server import ( diff --git a/examples/grpc/grpc-server/server/hello_gofr.go b/examples/grpc/grpc-server/server/hello_gofr.go index d13f573e7..ed976de70 100644 --- a/examples/grpc/grpc-server/server/hello_gofr.go +++ b/examples/grpc/grpc-server/server/hello_gofr.go @@ -1,10 +1,13 @@ // Code generated by gofr.dev/cli/gofr. DO NOT EDIT. +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + package server import ( "context" - "fmt" - "reflect" "gofr.dev/pkg/gofr" "gofr.dev/pkg/gofr/container" @@ -65,7 +68,7 @@ func RegisterHelloServerWithGofr(app *gofr.App, srv HelloServerWithGofr) { }) } -// GetGofrContext extracts the GoFr context from the original context +// getGofrContext extracts the GoFr context from the original context func (h *HelloServerWrapper) getGofrContext(ctx context.Context, req gofr.Request) *gofr.Context { return &gofr.Context{ Context: ctx, @@ -73,53 +76,3 @@ func (h *HelloServerWrapper) getGofrContext(ctx context.Context, req gofr.Reques Request: req, } } - -// -// Request Wrappers -type HelloRequestWrapper struct { - ctx context.Context - *HelloRequest -} - -func (h *HelloRequestWrapper) Context() context.Context { - return h.ctx -} - -func (h *HelloRequestWrapper) Param(s string) string { - return "" -} - -func (h *HelloRequestWrapper) PathParam(s string) string { - return "" -} - -func (h *HelloRequestWrapper) Bind(p interface{}) error { - ptr := reflect.ValueOf(p) - if ptr.Kind() != reflect.Ptr { - return fmt.Errorf("expected a pointer, got %T", p) - } - - hValue := reflect.ValueOf(h.HelloRequest).Elem() - ptrValue := ptr.Elem() - - for i := 0; i < hValue.NumField(); i++ { - field := hValue.Type().Field(i) - if field.Name == "state" || field.Name == "sizeCache" || field.Name == "unknownFields" { - continue - } - - if field.IsExported() { - ptrValue.Field(i).Set(hValue.Field(i)) - } - } - - return nil -} - -func (h *HelloRequestWrapper) HostName() string { - return "" -} - -func (h *HelloRequestWrapper) Params(s string) []string { - return nil -} diff --git a/examples/grpc/grpc-server/server/hello_server.go b/examples/grpc/grpc-server/server/hello_server.go index ca4f5e0f9..0ab98f3aa 100644 --- a/examples/grpc/grpc-server/server/hello_server.go +++ b/examples/grpc/grpc-server/server/hello_server.go @@ -1,5 +1,10 @@ package server +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + import ( "fmt" "gofr.dev/pkg/gofr" diff --git a/examples/grpc/grpc-server/server/request_gofr.go b/examples/grpc/grpc-server/server/request_gofr.go new file mode 100644 index 000000000..5e820a618 --- /dev/null +++ b/examples/grpc/grpc-server/server/request_gofr.go @@ -0,0 +1,63 @@ +// Code generated by gofr.dev/cli/gofr. DO NOT EDIT. +// versions: +// gofr-cli v0.6.0 +// gofr.dev v1.37.0 +// source: hello.proto + + +package server + +import ( + "context" + "fmt" + "reflect" +) + +// Request Wrappers +type HelloRequestWrapper struct { + ctx context.Context + *HelloRequest +} + +func (h *HelloRequestWrapper) Context() context.Context { + return h.ctx +} + +func (h *HelloRequestWrapper) Param(s string) string { + return "" +} + +func (h *HelloRequestWrapper) PathParam(s string) string { + return "" +} + +func (h *HelloRequestWrapper) Bind(p interface{}) error { + ptr := reflect.ValueOf(p) + if ptr.Kind() != reflect.Ptr { + return fmt.Errorf("expected a pointer, got %T", p) + } + + hValue := reflect.ValueOf(h.HelloRequest).Elem() + ptrValue := ptr.Elem() + + for i := 0; i < hValue.NumField(); i++ { + field := hValue.Type().Field(i) + if field.Name == "state" || field.Name == "sizeCache" || field.Name == "unknownFields" { + continue + } + + if field.IsExported() { + ptrValue.Field(i).Set(hValue.Field(i)) + } + } + + return nil +} + +func (h *HelloRequestWrapper) HostName() string { + return "" +} + +func (h *HelloRequestWrapper) Params(s string) []string { + return nil +} \ No newline at end of file