MCPcopy Create free account
hub / github.com/devfeel/dotweb / Handle

Method Handle

example/middleware/main.go:126–136  ·  view source on GitHub ↗
(ctx dotweb.Context)

Source from the content-addressed store, hash-verified

124}
125
126func (m *SimpleAuth) Handle(ctx dotweb.Context) error {
127 fmt.Println(time.Now(), "[SimpleAuth] begin request -> ", ctx.Request().RequestURI)
128 var err error
129 if ctx.QueryString("token") != m.exactToken {
130 ctx.Write(http.StatusUnauthorized, []byte("sorry, Unauthorized"))
131 } else {
132 err = m.Next(ctx)
133 }
134 fmt.Println(time.Now(), "[SimpleAuth] finish request ", err, " -> ", ctx.Request().RequestURI)
135 return err
136}
137
138func NewSimpleAuth(exactToken string) *SimpleAuth {
139 return &SimpleAuth{exactToken: exactToken}

Callers

nothing calls this directly

Calls 4

RequestMethod · 0.65
QueryStringMethod · 0.65
WriteMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected