httpcaddyfile: static_response -> respond; minor cleanups

This commit is contained in:
Matthew Holt 2019-09-16 11:04:18 -06:00
parent db4c73dd58
commit d030bfdae0
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
5 changed files with 17 additions and 11 deletions

View file

@ -29,7 +29,6 @@ func init() {
httpcaddyfile.RegisterHandlerDirective("encode", parseCaddyfile)
}
// TODO: This is a good example of why UnmarshalCaddyfile is still a good idea... hmm.
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
enc := new(Encode)
err := enc.UnmarshalCaddyfile(h.Dispenser)
@ -39,8 +38,6 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
return enc, nil
}
// TODO: Keep UnmarshalCaddyfile pattern?
// UnmarshalCaddyfile sets up the handler from Caddyfile tokens. Syntax:
//
// encode [<matcher>] <formats...> {

View file

@ -25,7 +25,6 @@ import (
func init() {
caddy.RegisterModule(StaticResponse{})
// TODO: Caddyfile directive
}
// StaticResponse implements a simple responder for static responses.
@ -46,7 +45,7 @@ func (StaticResponse) CaddyModule() caddy.ModuleInfo {
// UnmarshalCaddyfile sets up the handler from Caddyfile tokens. Syntax:
//
// static_response [<matcher>] <status> {
// respond [<matcher>] <status> {
// body <text>
// close
// }
@ -119,5 +118,8 @@ func (s StaticResponse) ServeHTTP(w http.ResponseWriter, r *http.Request, _ Hand
return nil
}
// Interface guard
var _ MiddlewareHandler = (*StaticResponse)(nil)
// Interface guards
var (
_ MiddlewareHandler = (*StaticResponse)(nil)
_ caddyfile.Unmarshaler = (*StaticResponse)(nil)
)