Skip to content

Chore: move the authentication middleware into droplet framework #1295

Description

@starsz

Feature request

Please describe your feature

Hi, I found the dorplet had split the http_input into http_injector and http_input. We can get the http.Request in droplect.Context.
So I think we can move those middleware:

r.Use(sessions.Sessions("session", store))
r.Use(filter.CORS(), filter.RequestId(), filter.RequestLogHandler(logger), filter.SchemaCheck(), filter.Authentication(), filter.RecoverHandler())
r.Use(static.Serve("/", static.LocalFile(filepath.Join(conf.WorkDir, conf.WebDir), false)))

into droplet framework. Then we can have a more clearer code and better response.

First, I want to move the authentication function into droplet.

Describe the solution you'd like

Use the droplet framework to do middleware orchestra work.

droplet.Option.Orchestrator = func(mws []droplet.Middleware) []droplet.Middleware {
var newMws []droplet.Middleware
// default middleware order: resp_reshape, auto_input, traffic_log
// We should put err_transform at second to catch all error
newMws = append(newMws, mws[0], &handler.ErrorTransformMiddleware{})
newMws = append(newMws, mws[1:]...)
return newMws
}

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

    Issue actions