Skip to content

Trailing slash in subrouter #111

Answered by vearutop
pboguslawski asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, it is possible with additional wrap that overrides route info of a handler, please check an example:

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"

	"github.com/go-chi/chi/v5"
	"github.com/swaggest/assertjson"
	"github.com/swaggest/rest"
	"github.com/swaggest/rest/chirouter"
	"github.com/swaggest/rest/nethttp"
	"github.com/swaggest/rest/web"
	swgui "github.com/swaggest/swgui/v4emb"
	"github.com/swaggest/usecase"
)

func dummy() usecase.Interactor {
	return usecase.NewInteractor(func(ctx context.Context, input struct{}, output *struct{}) error {
		println("dummy")
		return nil
	})
}

func main() {
	service := web.DefaultService()

	service.Route("/test", func(r chi.Router

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pboguslawski
Comment options

Answer selected by pboguslawski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants