Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Revel FAQs


May 15, 2021 Revel



How to put an existing http. Handlers integrated into Revel?

In the concept map, http. H andler is used to process user requests. Revel's processing is very simple, it simply creates a controller instance and passes the request to the filter chain.

Applications can consolidate existing https by overrideing the default handler. Handlers:

func installHandlers() {
    var (
        serveMux     = http.NewServeMux()
        revelHandler = revel.Server.Handler
    )
    serveMux.Handle("/",     revelHandler)
    serveMux.Handle("/path", myHandler)
    revel.Server.Handler = serveMux
}

func init() {
    revel.OnAppStart(installHandlers)
}

What is the relationship between interceptors, filters, and modules?

  1. A module is a package that can be inserted into a program. They can share controllers, views, resources, and other code across multiple Level programs (or third-party sources).

  2. A filter is a function that can be hooked up to a request to process a pipeline. They are generally used as a whole processing technique in applications to vertically separate application logic.

  3. Interceptors are a convenient way to encapsulate data and behavior because embedded types import their interceptors and fields. T his allows the interceptor to handle things such as verifying login cookies and saving this information to a field. Interceptors can be applied to one or more controllers.