FAQs

    Or the variable arguments of the Run method:

    1. f.Run("localhost") // => localhost:2830
    2. f.Run(8888) // => 0.0.0.0:8888
    3. f.Run("localhost", 8888) // => localhost:8888

    Alternatively, http.ListenAndServeopen in new window or can also be used to change the listen address:

    How do I do graceful shutdown?

    The package can be used to do graceful shutdown with the Flame instance:

    1. package main
    2. import (
    3. "net/http"
    4. "github.com/flamego/flamego"
    5. "github.com/ory/graceful"
    6. func main() {
    7. f := flamego.New()
    8. ...
    9. server := graceful.WithDefaults(
    10. &http.Server{
    11. Addr: "0.0.0.0:2830",
    12. Handler: f,
    13. },
    14. )
    15. // Handler error
    16. }
    17. }

    Below is an example of integrating with the net/http router for a single route "/user/info":

    • Code
    • Test
    1. $ curl -i http://localhost:2830/user/info
    2. The user is Joe

    Example: Integrating with Macaron

    Below is an example of integrating with the Macaron router for a single route "/user/info":

    • Code
    • Test
    1. $ curl -i http://localhost:2830/user/info
    2. The user is Joe

    What is the difference between inject.Invoker and inject.FastInvoker?

    The inject.InvokerFAQs - 图5open in new window is the default way that the Flame instance uses to invoke a function through reflection.

    Martini brought the brilliant idea of build a web framework with dependency injection in a magical experience. However, it has terrible performance and high memory usage. Some people are blaming the use of reflection for its slowness and memory footprint, but that is not fair by the way, most of people are using reflections every single day with marshalling and unmarshalling JSON in Go.

    Macaron achieved the reasonable performance and much lower memory usage. Unfortunately, it was not a properly designed product, or let’s be honest, there was no design. The origin of Macaron was to support the rapid development of the project, thus almost all things were inherited from some other web frameworks at the time.

    Absence of holistic architecture view and design principles have caused many bad decisions, including but not limited to:

    Why the default port is 2830?

    keyboard layout 2830