Skip to content

Commit

Permalink
De-exports initContext
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 17, 2024
1 parent 8898045 commit 0ef706b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *Server) url() string {
// initializes any Context type with the base ContextNoBody context.
//
// var ctx ContextWithBody[any] // does not work because it will create a ContextWithBody[any] with a nil value
func InitContext[Contextable ctxWithBody[Body], Body any](baseContext ContextNoBody) (Contextable, error) {
func initContext[Contextable ctxWithBody[Body], Body any](baseContext ContextNoBody) (Contextable, error) {
var c Contextable

err := validateParams(baseContext)
Expand Down Expand Up @@ -109,7 +109,7 @@ func HTTPHandler[ReturnType, Body any, Contextable ctxWithBody[Body]](s *Server,
templates = template.Must(s.template.Clone())
}

ctx, err := InitContext[Contextable](ContextNoBody{
ctx, err := initContext[Contextable](ContextNoBody{
Req: r,
Res: w,
readOptions: readOptions{
Expand Down
10 changes: 5 additions & 5 deletions serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestIni(t *testing.T) {
t.Run("can initialize ContextNoBody", func(t *testing.T) {
req := httptest.NewRequest("GET", "/ctx/error-in-rendering", nil)
w := httptest.NewRecorder()
ctx, err := InitContext[ContextNoBody](ContextNoBody{
ctx, err := initContext[ContextNoBody](ContextNoBody{
Req: req,
Res: w,
})
Expand All @@ -365,7 +365,7 @@ func TestIni(t *testing.T) {
t.Run("can initialize ContextNoBody", func(t *testing.T) {
req := httptest.NewRequest("GET", "/ctx/error-in-rendering", nil)
w := httptest.NewRecorder()
ctx, err := InitContext[*ContextNoBody](ContextNoBody{
ctx, err := initContext[*ContextNoBody](ContextNoBody{
Req: req,
Res: w,
})
Expand All @@ -379,7 +379,7 @@ func TestIni(t *testing.T) {
t.Run("can initialize ContextWithBody[string]", func(t *testing.T) {
req := httptest.NewRequest("GET", "/ctx/error-in-rendering", nil)
w := httptest.NewRecorder()
ctx, err := InitContext[*ContextWithBody[string]](ContextNoBody{
ctx, err := initContext[*ContextWithBody[string]](ContextNoBody{
Req: req,
Res: w,
})
Expand All @@ -393,7 +393,7 @@ func TestIni(t *testing.T) {
t.Run("can initialize ContextWithBody[struct]", func(t *testing.T) {
req := httptest.NewRequest("GET", "/ctx/error-in-rendering", nil)
w := httptest.NewRecorder()
ctx, err := InitContext[*ContextWithBody[ans]](ContextNoBody{
ctx, err := initContext[*ContextWithBody[ans]](ContextNoBody{
Req: req,
Res: w,
})
Expand All @@ -409,7 +409,7 @@ func TestIni(t *testing.T) {
w := httptest.NewRecorder()

require.Panics(t, func() {
InitContext[ctxWithBody[any]](ContextNoBody{
initContext[ctxWithBody[any]](ContextNoBody{
Req: req,
Res: w,
})
Expand Down

0 comments on commit 0ef706b

Please sign in to comment.