org.zodiac.netty.http.headers.WebSocketLocationHeader Maven / Gradle / Ivy
package org.zodiac.netty.http.headers;
import io.netty.handler.codec.http.HttpHeaderNames;
import java.net.MalformedURLException;
import java.net.URL;
import org.zodiac.sdk.toolkit.util.ExceptionUtil;
final class WebSocketLocationHeader extends AbstractHeader {
WebSocketLocationHeader() {
super(URL.class, HttpHeaderNames.WEBSOCKET_LOCATION);
}
@Override
public String toString(URL value) {
return value.toExternalForm();
}
@Override
public URL toValue(CharSequence value) {
try {
return new URL(value.toString());
} catch (MalformedURLException ex) {
return ExceptionUtil.chuck(ex);
}
}
}