com.ibasco.agql.core.AbstractWebRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agql-lib-core Show documentation
Show all versions of agql-lib-core Show documentation
The core library. Required by all agql modules.
/*
* Copyright (c) 2022 Asynchronous Game Query Library
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ibasco.agql.core;
import io.netty.handler.codec.http.HttpMethod;
import org.asynchttpclient.Request;
import org.asynchttpclient.RequestBuilder;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Abstract AbstractWebRequest class.
*
* @author Rafael Luis Ibasco
*/
@SuppressWarnings("all")
abstract public class AbstractWebRequest extends AbstractRequest {
private static final Logger log = LoggerFactory.getLogger(AbstractWebRequest.class);
private RequestBuilder requestBuilder;
/**
* Constructor for AbstractWebRequest.
*/
public AbstractWebRequest() {
//super(null);
requestBuilder = new RequestBuilder();
}
/**
* baseUrl.
*
* @param url
* a {@link java.lang.String} object
*/
protected void baseUrl(String url) {
request().setUrl(url);
}
/**
* request.
*
* @return a {@link org.asynchttpclient.RequestBuilder} object
*/
public final RequestBuilder request() {
return requestBuilder;
}
/**
* header.
*
* @param header
* a {@link java.lang.CharSequence} object
* @param value
* a {@link java.lang.String} object
*/
protected void header(CharSequence header, String value) {
request().addHeader(header, value);
}
/**
* method.
*
* @param method
* a {@link io.netty.handler.codec.http.HttpMethod} object
*/
protected void method(HttpMethod method) {
request().setMethod(method.name());
}
/**
* urlParam.
*
* @param name
* a {@link java.lang.String} object
* @param value
* a {@link java.lang.Object} object
*/
protected void urlParam(String name, Object value) {
RequestBuilder builder = request();
if (value == null)
return;
if (value instanceof Collection>) {
Collection
© 2015 - 2024 Weber Informatics LLC | Privacy Policy