All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmonix.servlet.Request Maven / Gradle / Ivy

There is a newer version: 1.6
Show newest version
/**
 * Copyright 2016 Peter Nerg
 * 

* 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 org.dmonix.servlet; import javascalautils.Option; import javascalautils.Try; import javax.servlet.http.HttpServletRequest; /** * Wrapper for the {@link HttpServletRequest} class. * @author Peter Nerg * @since 1.0 */ public final class Request { private final HttpServletRequest request; Request(HttpServletRequest request) { this.request = request; } /** * Get the wrapped {@link HttpServletRequest} * @return The original HTTP request */ public HttpServletRequest request() { return request; } /** * Get the path info as specified in the URI. * * @return The path info, i.e. the last part of the URI */ public Option getPathInfo() { return ParserUtils.getPathInfo(request); } /** * Parses an object from the json stream in the HTTP request * @param type The type to parse * @param The return type * @return The parsed object */ public Try fromJson(Class type) { return fromJson("UTF-8", type); } /** * Parses an object from the json stream in the HTTP request * @param charsetName The charset to expect * @param type The type to parse * @param The return type * @return The parsed object */ public Try fromJson(String charsetName, Class type) { return ParserUtils.fromJson(request, charsetName, type); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy