New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVC routing path name #1094

Open
edwinchana opened this Issue Sep 28, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@edwinchana

edwinchana commented Sep 28, 2018

I want to implement uppercase character like this path "${hostname}/organization/bulkLicense"
How to do it In MVC structure? thanks.

@kataras

This comment has been minimized.

Owner

kataras commented Sep 28, 2018

You mean:

app.Get("/{hostname}/organisation/bulkLicense")

To:

// it will be: {hostname}/organisation/bulklicense (note the lowercase "l")
func (c *MyController) GetByOrganisationBulklicense(hostname string) {
    // [...]
}

If you don't like this behavior you can always inject the controller with BeforeActivation (example here) and add your own naming convesion per route, i.e:

(read the code snippet's comments)

import (
   // [...]
   "github.com/kataras/iris/mvc"
)

// [...]

func (c *MyController) BeforeActivation(b mvc.BeforeActivation) {
    b.Handle("GET", "/{hostname}/organisation/bulkLicense", "HostnameOrganisationBulkLicense")
    // - first parameter is the HTTP method, to catch all you can use the "ALL" or "ANY".
    // - second parameter is the request path, like you always do, 
    //   keep note that {hostname} is same as {hostname:string}.
    // - third parameter is the CONTROLLER's FUNCTION NAME WHICH WILL HANDLE THIS REQUEST
    //   you can put any name you want here.

    // The `BeforeActivation` will be fired automatically by the framework, 
    // you just add this and the `AfterActivation` to your controller and 
    // Iris will take care of your controller.
}

func (c *MyController) AfterActivation(a mvc.AfterActivation) { 
    // keep it empty if you don't need this.
}

// naming is up to you when you manually register the function with a route via 
// `BeforeActivation#Handle` (look above)
func (c *MyController) HostnameOrganisationBulkLicense(hostname string) {
    // [...]
}

Hope that was helpful enough, if not please post again and I will answer you pretty fast:)

Pleas star the iris github repository, I am working on version 11 at "v11" branch and I need support for my time, a star will cost you just 2 seconds. Thank you a lot!

@edwinchana

This comment has been minimized.

edwinchana commented Sep 28, 2018

Got It! This helped me a lot. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment