(ctx dotweb.Context)
| 124 | } |
| 125 | |
| 126 | func (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 | |
| 138 | func NewSimpleAuth(exactToken string) *SimpleAuth { |
| 139 | return &SimpleAuth{exactToken: exactToken} |
nothing calls this directly
no test coverage detected