我在dropwizard项目中使用groovy并且在未指定@QueryParam时尝试返回404而不是500。
我尝试过使用javax.validation.constraints.NotNull以及com.sun.isstack.NotNull中的@NotNull标志,但都没有正常工作。
为了澄清,当用户没有输入其中一个特定参数的参数时,我想返回404:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (Column, Index, Date, DateTime, Numeric, BigInteger, String, ForeignKey, Boolean)
Base = declarative_base()
class Project(Base):
"""sqlalchemy ORM for my table."""
__tablename__ = "table1"
id = Column("id", BigIntegerID, primary_key=True, autoincrement=True)
date = Column("date", Date, nullable=False)
value = Column("value", Numeric(20, 8))
...
...
答案 0 :(得分:1)
尝试为def a():
data = get_data_somewhere()
for val in data:
yield val
def b():
a_gen = a()
val = next(a_gen)
try:
while True:
if val == "foo":
received = yield val
val = a_gen.send(received)
else:
val = a_gen.send(None)
except StopIteration:
pass
finally:
del a_gen
(依赖项包含在Dropwizard中):
com.google.common.base.Optional