LoginSignup
1
0

More than 5 years have passed since last update.

Joobyで全リクエストに対してヘッダを出力するModuleのサンプル

Last updated at Posted at 2017-11-28

Joobyで全リクエストに対してヘッダを出力する、というようなことをしたい時、Moduleを実装する必要があるようです。
そういうModuleを実装してみたので、ご参考まで。

class AppendAccessControlForDevEnv : Jooby.Module {
    override fun configure(env: Env?, conf: Config?, binder: Binder?) {
        if (env != null) {
            env.router().get("*") {req, rsp ->
                rsp.header("Access-Control-Allow-Origin", "http://localhost:8090")
            }
        }
    }
}



class App : Kooby({
    use(AppendAccessControlForDevEnv())

    get("/hello") { "Hello" }
})
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0