Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple endpoints #5

Open
diegobernardes opened this issue Jun 21, 2016 · 7 comments
Open

Support for multiple endpoints #5

diegobernardes opened this issue Jun 21, 2016 · 7 comments
Assignees
Milestone

Comments

@diegobernardes
Copy link

diegobernardes commented Jun 21, 2016

There is any problem having multiple endpoints?

/contact/y
/contact/x
/contact/z

Maybe the DSL could contemplate, something like this:

mailout {
  maillog  mail.log
  errorlog mail.error.log
  to       [email protected]

  subject "Hello"
  body    template.txt

  username "username"
  password "password"
  host     "smtp.gmail.com"
  port     587

  /contato/x {
    maillog  mail2.log
    errorlog mail2.error.log
  }

  /contato/y {
    subject "Hello"
    body    template.txt
  }
}
@SchumacherFM
Copy link
Owner

Cool idea! I like it! Would this be a breaking change to the configuration?

I do have to refactor this module because the Caddy module API will change or has already changed. Then I can implement it.

@mholt
Copy link
Contributor

mholt commented Jun 21, 2016

Since we don't like nesting in the Caddyfile, typically the way to do this is to use the mailout directive multiple times, each one specifying a "rule" or a "config" of sorts. It may produce some duplicate lines but I think in general we prefer the simplicity.

Now, you're of course welcome to do nesting but the parser (caddyfile.Dispenser) doesn't really support that first-class, it would need to be upgraded to do so. We hacked some support for nested blocks into log and errors to configure log rolling (just to see what it would be like), but I don't really like the complexity...

@diegobernardes
Copy link
Author

Ok, so it's better follow caddy style.

@SchumacherFM could multiple endpoints be made with multiple directives? Add a little of duplication, but, in the end, gonna work the same way.

@SchumacherFM
Copy link
Owner

Thank you for the input @mholt very worth! I didn't know that nesting wasn't possible and also I do not want to spend too much time on implementing nesting. Multiple directies/endpoints would AFAIK easy to implement.

@SchumacherFM SchumacherFM added this to the 2.0.0 milestone Jul 8, 2016
@SchumacherFM SchumacherFM self-assigned this Jul 8, 2016
@stp-ip
Copy link

stp-ip commented Nov 18, 2016

This is what I tried before realizing it supports only one endpoint.

    :8080 {
      mailout / {
      to [email protected]
      subject "Contact request from {{ .Form.Get \"site\" }}"
      body /etc/config/template.txt
      username "[email protected]"
      password "{$SMTP_PASSWORD}"
      host "smtp.example.com"
      port 587
      }
      cors / https://example.com
    }
    :8080/test/ {
      mailout /test/ {
      to [email protected]
      subject "[TEST] Contact request from {{ .Form.Get \"site\" }}"
      body /etc/config/template.txt
      username "[email protected]"
      password "{$SMTP_PASSWORD}"
      host "smtp.example.com"
      port 587
      }
      cors /test/ http://localhost
    }

@SchumacherFM
Copy link
Owner

It's a total refactoring of the module ... might take some time.

@stp-ip
Copy link

stp-ip commented Dec 4, 2016

Don't stress yourself. One can already run multiple instances. Not perfect but manageable. If it can be done in the long term, it would make mailout match the other plugin behaviours more closely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants