Skip to content

Work with Static File,route '*filepath' conflicts #1044

@housirvip

Description

@housirvip
engine.Static("/", "dist")
user := engine.Group("/user")
user.POST("/login", handler.Login)
user.POST("/reg", handler.Register)
user.GET("/sub", handler.Subscribe)
panic: path segment '/user/sub' conflicts with existing wildcard '/*filepath' in path '/user/sub'

Then ,if I delete all GET method route , it work good.
So ,how to use gin with angular2 gracefully? Thank you very much

Activity

changed the title [-]Work with angular2,route '*filepath' conflicts[/-] [+]Work with Static File,route '*filepath' conflicts[/+] on Aug 2, 2017
javierprovecho

javierprovecho commented on Aug 2, 2017

@javierprovecho
Member

engine.Static is designed for paths like /static, not a root path combined with other handlers.

you should use static middleware, see its example 😃
https://github.com/gin-contrib/static#canonical-example

r.Use(static.Serve("/", static.LocalFile("/tmp", false)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @javierprovecho@housirvip

        Issue actions

          Work with Static File,route '*filepath' conflicts · Issue #1044 · gin-gonic/gin